home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / eplain / doc / texinfo.tex (.txt) < prev    next >
LaTeX Document  |  1994-03-30  |  136KB  |  3,309 lines

  1. %% TeX macros to handle texinfo files
  2. %   Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc.
  3. %This texinfo.tex file is free software; you can redistribute it and/or
  4. %modify it under the terms of the GNU General Public License as
  5. %published by the Free Software Foundation; either version 2, or (at
  6. %your option) any later version.
  7. %This texinfo.tex file is distributed in the hope that it will be
  8. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  10. %General Public License for more details.
  11. %You should have received a copy of the GNU General Public License
  12. %along with this texinfo.tex file; see the file COPYING.  If not, write
  13. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  14. %USA.
  15. %In other words, you are welcome to use, share and improve this program.
  16. %You are forbidden to forbid anyone else to use, share and improve
  17. %what you give them.   Help stamp out software-hoarding!
  18. % This automatically updates the version number based on RCS.
  19. \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2/K}}
  20. \deftexinfoversion$Revision: 2.124 $
  21. \message{Loading texinfo package [Version \texinfoversion]:}
  22. % Print the version number if in a .fmt file.
  23. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  24. % Save some parts of plain tex whose names we will redefine.
  25. \let\ptexlbrace=\{
  26. \let\ptexrbrace=\}
  27. \let\ptexdots=\dots
  28. \let\ptexdot=\.
  29. \let\ptexstar=\*
  30. \let\ptexend=\end
  31. \let\ptexbullet=\bullet
  32. \let\ptexb=\b
  33. \let\ptexc=\c
  34. \let\ptexi=\i
  35. \let\ptext=\t
  36. \let\ptexl=\l
  37. \let\ptexL=\L
  38. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  39. \message{Basics,}
  40. \chardef\other=12
  41. % If this character appears in an error message or help string, it
  42. % starts a new line in the output.
  43. \newlinechar = `^^J
  44. % Set up fixed words for English.
  45. \ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi%
  46. \def\putwordInfo{Info}%
  47. \ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi%
  48. \ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi%
  49. \ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi%
  50. \ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi%
  51. \ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi%
  52. \ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi%
  53. \ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi%
  54. \ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi%
  55. \ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi%
  56. % Ignore a token.
  57. \def\gobble#1{}
  58. \hyphenation{ap-pen-dix}
  59. \hyphenation{mini-buf-fer mini-buf-fers}
  60. \hyphenation{eshell}
  61. % Margin to add to right of even pages, to left of odd pages.
  62. \newdimen \bindingoffset  \bindingoffset=0pt
  63. \newdimen \normaloffset   \normaloffset=\hoffset
  64. \newdimen\pagewidth \newdimen\pageheight
  65. \pagewidth=\hsize \pageheight=\vsize
  66. % Sometimes it is convenient to have everything in the transcript file
  67. % and nothing on the terminal.  We don't just call \tracingall here,
  68. % since that produces some useless output on the terminal.
  69. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  70. \def\loggingall{\tracingcommands2 \tracingstats2
  71.    \tracingpages1 \tracingoutput1 \tracinglostchars1
  72.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  73.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  74. %---------------------Begin change-----------------------
  75. %%%% For @cropmarks command.
  76. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  77. \newdimen\cornerlong \newdimen\cornerthick
  78. \newdimen \topandbottommargin
  79. \newdimen \outerhsize \newdimen \outervsize
  80. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  81. \outerhsize=7in
  82. %\outervsize=9.5in
  83. % Alternative @smallbook page size is 9.25in
  84. \outervsize=9.25in
  85. \topandbottommargin=.75in
  86. %---------------------End change-----------------------
  87. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  88. % does insertions itself, but you have to call it yourself.
  89. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  90. \def\onepageout#1{\hoffset=\normaloffset
  91. \ifodd\pageno  \advance\hoffset by \bindingoffset
  92. \else \advance\hoffset by -\bindingoffset\fi
  93. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  94. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  95. {\let\hsize=\pagewidth \makefootline}}}%
  96. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  97. %%%% For @cropmarks command %%%%
  98. % Here is a modification of the main output routine for Near East Publications
  99. % This provides right-angle cropmarks at all four corners.
  100. % The contents of the page are centerlined into the cropmarks,
  101. % and any desired binding offset is added as an \hskip on either
  102. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  103. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  104. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  105.          \shipout
  106.          \vbox to \outervsize{\hsize=\outerhsize
  107.                  \vbox{\line{\ewtop\hfill\ewtop}}
  108.                  \nointerlineskip
  109.                  \line{\vbox{\moveleft\cornerthick\nstop}
  110.                        \hfill
  111.                        \vbox{\moveright\cornerthick\nstop}}
  112.                  \vskip \topandbottommargin
  113.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  114.             \vbox{
  115.             {\let\hsize=\pagewidth \makeheadline}
  116.             \pagebody{#1}
  117.             {\let\hsize=\pagewidth \makefootline}}
  118.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  119.          \vskip \topandbottommargin plus1fill minus1fill
  120.                  \boxmaxdepth\cornerthick
  121.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  122.                        \hfill
  123.                        \vbox{\moveright\cornerthick\nsbot}}
  124.                  \nointerlineskip
  125.                  \vbox{\line{\ewbot\hfill\ewbot}}
  126.   \advancepageno
  127.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  128. % Do @cropmarks to get crop marks
  129. \def\cropmarks{\let\onepageout=\croppageout }
  130. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  131. {\catcode`\@ =11
  132. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  133. \dimen@=\dp#1 \unvbox#1
  134. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  135. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  136. % Here are the rules for the cropmarks.  Note that they are
  137. % offset so that the space between them is truly \outerhsize or \outervsize
  138. % (P. A. MacKay, 12 November, 1986)
  139. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  140. \def\nstop{\vbox
  141.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  142. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  143. \def\nsbot{\vbox
  144.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  145. % Parse an argument, then pass it to #1.  The argument is the rest of
  146. % the input line (except we remove a trailing comment).  #1 should be a
  147. % macro which expects an ordinary undelimited TeX argument.
  148. \def\parsearg#1{%
  149.   \let\next = #1%
  150.   \begingroup
  151.     \obeylines
  152.     \futurelet\temp\parseargx
  153. % If the next token is an obeyed space (from an @example environment or
  154. % the like), remove it and recurse.  Otherwise, we're done.
  155. \def\parseargx{%
  156.   % \obeyedspace is defined far below, after the definition of \sepspaces.
  157.   \ifx\obeyedspace\temp
  158.     \expandafter\parseargdiscardspace
  159.   \else
  160.     \expandafter\parseargline
  161.   \fi
  162. % Remove a single space (as the delimiter token to the macro call).
  163. {\obeyspaces %
  164.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  165. {\obeylines %
  166.   \gdef\parseargline#1^^M{%
  167.     \endgroup % End of the group started in \parsearg.
  168.     %
  169.     % First remove any @c comment, then any @comment.
  170.     % Result of each macro is put in \toks0.
  171.     \argremovec #1\c\relax %
  172.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  173.     %
  174.     % Call the caller's macro, saved as \next in \parsearg.
  175.     \expandafter\next\expandafter{\the\toks0}%
  176. % Since all \c{,omment} does is throw away the argument, we can let TeX
  177. % do that for us.  The \relax here is matched by the \relax in the call
  178. % in \parseargline; it could be more or less anything, its purpose is
  179. % just to delimit the argument to the \c.
  180. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  181. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  182. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  183. %    @end itemize  @c foo
  184. % will have two active spaces as part of the argument with the
  185. % `itemize'.  Here we remove all active spaces from #1, and assign the
  186. % result to \toks0.
  187. % This loses if there are any *other* active characters besides spaces
  188. % in the argument -- _ ^ +, for example -- since they get expanded.
  189. % Fortunately, Texinfo does not define any such commands.  (If it ever
  190. % does, the catcode of the characters in questionwill have to be changed
  191. % here.)  But this means we cannot call \removeactivespaces as part of
  192. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  193. % that \parsearg gets might well have any character at all in it.
  194. \def\removeactivespaces#1{%
  195.   \begingroup
  196.     \ignoreactivespaces
  197.     \edef\temp{#1}%
  198.     \global\toks0 = \expandafter{\temp}%
  199.   \endgroup
  200. % Change the active space to expand to nothing.
  201. \begingroup
  202.   \obeyspaces
  203.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  204. \endgroup
  205. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  206. %% These are used to keep @begin/@end levels from running away
  207. %% Call \inENV within environments (after a \begingroup)
  208. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  209. \def\ENVcheck{%
  210. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  211. \endgroup\fi} % This is not perfect, but it should reduce lossage
  212. % @begin foo  is the same as @foo, for now.
  213. \newhelp\EMsimple{Type <Return> to continue.}
  214. \outer\def\begin{\parsearg\beginxxx}
  215. \def\beginxxx #1{%
  216. \expandafter\ifx\csname #1\endcsname\relax
  217. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  218. \csname #1\endcsname\fi}
  219. % @end foo executes the definition of \Efoo.
  220. \def\end{\parsearg\endxxx}
  221. \def\endxxx #1{%
  222.   \removeactivespaces{#1}%
  223.   \edef\endthing{\the\toks0}%
  224.   \expandafter\ifx\csname E\endthing\endcsname\relax
  225.     \expandafter\ifx\csname \endthing\endcsname\relax
  226.       % There's no \foo, i.e., no ``environment'' foo.
  227.       \errhelp = \EMsimple
  228.       \errmessage{Undefined command `@end \endthing'}%
  229.     \else
  230.       \unmatchedenderror\endthing
  231.     \fi
  232.   \else
  233.     % Everything's ok; the right environment has been started.
  234.     \csname E\endthing\endcsname
  235.   \fi
  236. % There is an environment #1, but it hasn't been started.  Give an error.
  237. \def\unmatchedenderror#1{%
  238.   \errhelp = \EMsimple
  239.   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  240. % Define the control sequence \E#1 to give an unmatched @end error.
  241. \def\defineunmatchedend#1{%
  242.   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  243. % Single-spacing is done by various environments (specifically, in
  244. % \nonfillstart and \quotations).
  245. \newskip\singlespaceskip \singlespaceskip = 12.5pt
  246. \def\singlespace{%
  247.   % Why was this kern here?  It messes up equalizing space above and below
  248.   % environments.  --karl, 6may93
  249.   %{\advance \baselineskip by -\singlespaceskip
  250.   %\kern \baselineskip}%
  251.   \setleading \singlespaceskip
  252. %% Simple single-character @ commands
  253. % @@ prints an @
  254. % Kludge this until the fonts are right (grr).
  255. \def\@{{\tt \char '100}}
  256. % This is turned off because it was never documented
  257. % and you can use @w{...} around a quote to suppress ligatures.
  258. %% Define @` and @' to be the same as ` and '
  259. %% but suppressing ligatures.
  260. %\def\`{{`}}
  261. %\def\'{{'}}
  262. % Used to generate quoted braces.
  263. \def\mylbrace {{\tt \char '173}}
  264. \def\myrbrace {{\tt \char '175}}
  265. \let\{=\mylbrace
  266. \let\}=\myrbrace
  267. % @: forces normal size whitespace following.
  268. \def\:{\spacefactor=1000 }
  269. % @* forces a line break.
  270. \def\*{\hfil\break\hbox{}\ignorespaces}
  271. % @. is an end-of-sentence period.
  272. \def\.{.\spacefactor=3000 }
  273. % @w prevents a word break.  Without the \leavevmode, @w at the
  274. % beginning of a paragraph, when TeX is still in vertical mode, would
  275. % produce a whole line of output instead of starting the paragraph.
  276. \def\w#1{\leavevmode\hbox{#1}}
  277. % @group ... @end group forces ... to be all on one page, by enclosing
  278. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  279. % to keep its height that of a normal line.  According to the rules for
  280. % \topskip (p.114 of the TeXbook), the glue inserted is
  281. % max (\topskip - \ht (first item), 0).  If that height is large,
  282. % therefore, no glue is inserted, and the space between the headline and
  283. % the text is small, which looks bad.
  284. \def\group{\begingroup
  285.   \ifnum\catcode13=\active \else
  286.     \errhelp = \groupinvalidhelp
  287.     \errmessage{@group invalid in context where filling is enabled}%
  288.   \fi
  289.   % The \vtop we start below produces a box with normal height and large
  290.   % depth; thus, TeX puts \baselineskip glue before it, and (when the
  291.   % next line of text is done) \lineskip glue after it.  (See p.82 of
  292.   % the TeXbook.)  Thus, space below is not quite equal to space
  293.   % above.  But it's pretty close.
  294.   \def\Egroup{%
  295.     \egroup           % End the \vtop.
  296.     \endgroup         % End the \group.
  297.   \vtop\bgroup
  298.     % We have to put a strut on the last line in case the @group is in
  299.     % the midst of an example, rather than completely enclosing it.
  300.     % Otherwise, the interline space between the last line of the group
  301.     % and the first line afterwards is too small.  But we can't put the
  302.     % strut in \Egroup, since there it would be on a line by itself.
  303.     % Hence this just inserts a strut at the beginning of each line.
  304.     \everypar = {\strut}%
  305.     %
  306.     % Since we have a strut on every line, we don't need any of TeX's
  307.     % normal interline spacing.
  308.     \offinterlineskip
  309.     %
  310.     % OK, but now we have to do something about blank
  311.     % lines in the input in @example-like environments, which normally
  312.     % just turn into \lisppar, which will insert no space now that we've
  313.     % turned off the interline space.  Simplest is to make them be an
  314.     % empty paragraph.
  315.     \ifx\par\lisppar
  316.       \edef\par{\leavevmode \par}%
  317.       %
  318.       % Reset ^^M's definition to new definition of \par.
  319.       \obeylines
  320.     \fi
  321.     %
  322.     % Do @comment since we are called inside an environment such as
  323.     % @example, where each end-of-line in the input causes an
  324.     % end-of-line in the output.  We don't want the end-of-line after
  325.     % the `@group' to put extra space in the output.  Since @group
  326.     % should appear on a line by itself (according to the Texinfo
  327.     % manual), we don't worry about eating any user text.
  328.     \comment
  329. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  330. % message, so this ends up printing `@group can only ...'.
  331. \newhelp\groupinvalidhelp{%
  332. group can only be used in environments such as @example,^^J%
  333. where each line of input produces a line of output.}
  334. % @need space-in-mils
  335. % forces a page break if there is not space-in-mils remaining.
  336. \newdimen\mil  \mil=0.001in
  337. \def\need{\parsearg\needx}
  338. % Old definition--didn't work.
  339. %\def\needx #1{\par %
  340. %% This method tries to make TeX break the page naturally
  341. %% if the depth of the box does not fit.
  342. %{\baselineskip=0pt%
  343. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  344. %\prevdepth=-1000pt
  345. \def\needx#1{%
  346.   % Go into vertical mode, so we don't make a big box in the middle of a
  347.   % paragraph.
  348.   \par
  349.   % Don't add any leading before our big empty box, but allow a page
  350.   % break, since the best break might be right here.
  351.   \allowbreak
  352.   \nointerlineskip
  353.   \vtop to #1\mil{\vfil}%
  354.   % TeX does not even consider page breaks if a penalty added to the
  355.   % main vertical list is 10000 or more.  But in order to see if the
  356.   % empty box we just added fits on the page, we must make it consider
  357.   % page breaks.  On the other hand, we don't want to actually break the
  358.   % page after the empty box.  So we use a penalty of 9999.
  359.   % There is an extremely small chance that TeX will actually break the
  360.   % page at this \penalty, if there are no other feasible breakpoints in
  361.   % sight.  (If the user is using lots of big @group commands, which
  362.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  363.   % good page breaking, for example.)  However, I could not construct an
  364.   % example where a page broke at this \penalty; if it happens in a real
  365.   % document, then we can reconsider our strategy.
  366.   \penalty9999
  367.   % Back up by the size of the box, whether we did a page break or not.
  368.   \kern -#1\mil
  369.   % Do not allow a page break right after this kern.
  370.   \nobreak
  371. % @br   forces paragraph break
  372. \let\br = \par
  373. % @dots{}  output some dots
  374. \def\dots{$\ldots$}
  375. % @page    forces the start of a new page
  376. \def\page{\par\vfill\supereject}
  377. % @exdent text....
  378. % outputs text on separate line in roman font, starting at standard page margin
  379. % This records the amount of indent in the innermost environment.
  380. % That's how much \exdent should take out.
  381. \newskip\exdentamount
  382. % This defn is used inside fill environments such as @defun.
  383. \def\exdent{\parsearg\exdentyyy}
  384. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  385. % This defn is used inside nofill environments such as @example.
  386. \def\nofillexdent{\parsearg\nofillexdentyyy}
  387. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  388. \leftline{\hskip\leftskip{\rm#1}}}}
  389. %\hbox{{\rm#1}}\hfil\break}}
  390. % @include file    insert text of that file as input.
  391. \def\include{\parsearg\includezzz}
  392. %Use \input\thisfile to avoid blank after \input, which may be an active
  393. %char (in which case the blank would become the \input argument).
  394. %The grouping keeps the value of \thisfile correct even when @include
  395. %is nested.
  396. \def\includezzz #1{\begingroup
  397. \def\thisfile{#1}\input\thisfile
  398. \endgroup}
  399. \def\thisfile{}
  400. % @center line   outputs that line, centered
  401. \def\center{\parsearg\centerzzz}
  402. \def\centerzzz #1{{\advance\hsize by -\leftskip
  403. \advance\hsize by -\rightskip
  404. \centerline{#1}}}
  405. % @sp n   outputs n lines of vertical space
  406. \def\sp{\parsearg\spxxx}
  407. \def\spxxx #1{\par \vskip #1\baselineskip}
  408. % @comment ...line which is ignored...
  409. % @c is the same as @comment
  410. % @ignore ... @end ignore  is another way to write a comment
  411. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  412. \parsearg \commentxxx}
  413. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  414. \let\c=\comment
  415. % Prevent errors for section commands.
  416. % Used in @ignore and in failing conditionals.
  417. \def\ignoresections{%
  418. \let\chapter=\relax
  419. \let\unnumbered=\relax
  420. \let\top=\relax
  421. \let\unnumberedsec=\relax
  422. \let\unnumberedsection=\relax
  423. \let\unnumberedsubsec=\relax
  424. \let\unnumberedsubsection=\relax
  425. \let\unnumberedsubsubsec=\relax
  426. \let\unnumberedsubsubsection=\relax
  427. \let\section=\relax
  428. \let\subsec=\relax
  429. \let\subsubsec=\relax
  430. \let\subsection=\relax
  431. \let\subsubsection=\relax
  432. \let\appendix=\relax
  433. \let\appendixsec=\relax
  434. \let\appendixsection=\relax
  435. \let\appendixsubsec=\relax
  436. \let\appendixsubsection=\relax
  437. \let\appendixsubsubsec=\relax
  438. \let\appendixsubsubsection=\relax
  439. \let\contents=\relax
  440. \let\smallbook=\relax
  441. \let\titlepage=\relax
  442. % Used in nested conditionals, where we have to parse the Texinfo source
  443. % and so want to turn off most commands, in case they are used
  444. % incorrectly.
  445. \def\ignoremorecommands{%
  446.   \let\defcv = \relax
  447.   \let\deffn = \relax
  448.   \let\deffnx = \relax
  449.   \let\defindex = \relax
  450.   \let\defivar = \relax
  451.   \let\defmac = \relax
  452.   \let\defmethod = \relax
  453.   \let\defop = \relax
  454.   \let\defopt = \relax
  455.   \let\defspec = \relax
  456.   \let\deftp = \relax
  457.   \let\deftypefn = \relax
  458.   \let\deftypefun = \relax
  459.   \let\deftypevar = \relax
  460.   \let\deftypevr = \relax
  461.   \let\defun = \relax
  462.   \let\defvar = \relax
  463.   \let\defvr = \relax
  464.   \let\ref = \relax
  465.   \let\xref = \relax
  466.   \let\printindex = \relax
  467.   \let\pxref = \relax
  468.   \let\settitle = \relax
  469.   \let\include = \relax
  470.   \let\lowersections = \relax
  471.   \let\down = \relax
  472.   \let\raisesections = \relax
  473.   \let\up = \relax
  474.   \let\set = \relax
  475.   \let\clear = \relax
  476.   \let\item = \relax
  477.   \let\message = \relax
  478. % Ignore @ignore ... @end ignore.
  479. \def\ignore{\doignore{ignore}}
  480. % Also ignore @ifinfo, @menu, and @direntry text.
  481. \def\ifinfo{\doignore{ifinfo}}
  482. \def\menu{\doignore{menu}}
  483. \def\direntry{\doignore{direntry}}
  484. % Ignore text until a line `@end #1'.
  485. \def\doignore#1{\begingroup
  486.   % Don't complain about control sequences we have declared \outer.
  487.   \ignoresections
  488.   % Define a command to swallow text until we reach `@end #1'.
  489.   \long\def\doignoretext##1\end #1{\enddoignore}%
  490.   % Make sure that spaces turn into tokens that match what \doignoretext wants.
  491.   \catcode32 = 10
  492.   % And now expand that command.
  493.   \doignoretext
  494. % What we do to finish off ignored text.
  495. \def\enddoignore{\endgroup\ignorespaces}%
  496. \newif\ifwarnedobs\warnedobsfalse
  497. \def\obstexwarn{%
  498.   \ifwarnedobs\relax\else
  499.   % We need to warn folks that they may have trouble with TeX 3.0.
  500.   % This uses \immediate\write16 rather than \message to get newlines.
  501.     \immediate\write16{}
  502.     \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
  503.     \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
  504.     \immediate\write16{If you are running another version of TeX, relax.}
  505.     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
  506.     \immediate\write16{  Then upgrade your TeX installation if you can.}
  507.     \immediate\write16{If you are stuck with version 3.0, run the}
  508.     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
  509.     \immediate\write16{  to use a workaround.}
  510.     \immediate\write16{}
  511.     \warnedobstrue
  512.     \fi
  513. % **In TeX 3.0, setting text in \nullfont hangs tex.  For a
  514. % workaround (which requires the file ``dummy.tfm'' to be installed),
  515. % uncomment the following line:
  516. %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
  517. % Ignore text, except that we keep track of conditional commands for
  518. % purposes of nesting, up to an `@end #1' command.
  519. \def\nestedignore#1{%
  520.   \obstexwarn
  521.   % We must actually expand the ignored text to look for the @end
  522.   % command, so that nested ignore constructs work.  Thus, we put the
  523.   % text into a \vbox and then do nothing with the result.  To minimize
  524.   % the change of memory overflow, we follow the approach outlined on
  525.   % page 401 of the TeXbook: make the current font be a dummy font.
  526.   \setbox0 = \vbox\bgroup
  527.     % Don't complain about control sequences we have declared \outer.
  528.     \ignoresections
  529.     %
  530.     % Define `@end #1' to end the box, which will in turn undefine the
  531.     % @end command again.
  532.     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  533.     %
  534.     % We are going to be parsing Texinfo commands.  Most cause no
  535.     % trouble when they are used incorrectly, but some commands do
  536.     % complicated argument parsing or otherwise get confused, so we
  537.     % undefine them.
  538.     %
  539.     % We can't do anything about stray @-signs, unfortunately;
  540.     % they'll produce `undefined control sequence' errors.
  541.     \ignoremorecommands
  542.     %
  543.     % Set the current font to be \nullfont, a TeX primitive, and define
  544.     % all the font commands to also use \nullfont.  We don't use
  545.     % dummy.tfm, as suggested in the TeXbook, because not all sites
  546.     % might have that installed.  Therefore, math mode will still
  547.     % produce output, but that should be an extremely small amount of
  548.     % stuff compared to the main input.
  549.     %
  550.     \nullfont
  551.     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
  552.     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
  553.     \let\tensf = \nullfont
  554.     % Similarly for index fonts (mostly for their use in
  555.     % smallexample)
  556.     \let\indrm = \nullfont  \let\indit = \nullfont  \let\indsl = \nullfont
  557.     \let\indbf = \nullfont  \let\indtt = \nullfont  \let\indsc = \nullfont
  558.     \let\indsf = \nullfont
  559.     %
  560.     % Don't complain when characters are missing from the fonts.
  561.     \tracinglostchars = 0
  562.     %
  563.     % Don't bother to do space factor calculations.
  564.     \frenchspacing
  565.     %
  566.     % Don't report underfull hboxes.
  567.     \hbadness = 10000
  568.     %
  569.     % Do minimal line-breaking.
  570.     \pretolerance = 10000
  571.     %
  572.     % Do not execute instructions in @tex
  573.     \def\tex{\doignore{tex}}
  574. % @set VAR sets the variable VAR to an empty value.
  575. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  576. % Since we want to separate VAR from REST-OF-LINE (which might be
  577. % empty), we can't just use \parsearg; we have to insert a space of our
  578. % own to delimit the rest of the line, and then take it out again if we
  579. % didn't need it.
  580. \def\set{\parsearg\setxxx}
  581. \def\setxxx#1{\setyyy#1 \endsetyyy}
  582. \def\setyyy#1 #2\endsetyyy{%
  583.   \def\temp{#2}%
  584.   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  585.   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  586.   \fi
  587. \def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}}
  588. % @clear VAR clears (i.e., unsets) the variable VAR.
  589. \def\clear{\parsearg\clearxxx}
  590. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  591. % @value{foo} gets the text saved in variable foo.
  592. \def\value#1{\expandafter
  593.         \ifx\csname SET#1\endcsname\relax
  594.             {\{No value for ``#1''\}}
  595.         \else \csname SET#1\endcsname \fi}
  596. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  597. % with @set.
  598. \def\ifset{\parsearg\ifsetxxx}
  599. \def\ifsetxxx #1{%
  600.   \expandafter\ifx\csname SET#1\endcsname\relax
  601.     \expandafter\ifsetfail
  602.   \else
  603.     \expandafter\ifsetsucceed
  604.   \fi
  605. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  606. \def\ifsetfail{\nestedignore{ifset}}
  607. \defineunmatchedend{ifset}
  608. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  609. % defined with @set, or has been undefined with @clear.
  610. \def\ifclear{\parsearg\ifclearxxx}
  611. \def\ifclearxxx #1{%
  612.   \expandafter\ifx\csname SET#1\endcsname\relax
  613.     \expandafter\ifclearsucceed
  614.   \else
  615.     \expandafter\ifclearfail
  616.   \fi
  617. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  618. \def\ifclearfail{\nestedignore{ifclear}}
  619. \defineunmatchedend{ifclear}
  620. % @iftex always succeeds; we read the text following, through @end
  621. % iftex).  But `@end iftex' should be valid only after an @iftex.
  622. \def\iftex{\conditionalsucceed{iftex}}
  623. \defineunmatchedend{iftex}
  624. % We can't just want to start a group at @iftex (for example) and end it
  625. % at @end iftex, since then @set commands inside the conditional have no
  626. % effect (they'd get reverted at the end of the group).  So we must
  627. % define \Eiftex to redefine itself to be its previous value.  (We can't
  628. % just define it to fail again with an ``unmatched end'' error, since
  629. % the @ifset might be nested.)
  630. \def\conditionalsucceed#1{%
  631.   \edef\temp{%
  632.     % Remember the current value of \E#1.
  633.     \let\nece{prevE#1} = \nece{E#1}%
  634.     %
  635.     % At the `@end #1', redefine \E#1 to be its previous value.
  636.     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  637.   \temp
  638. % We need to expand lots of \csname's, but we don't want to expand the
  639. % control sequences after we've constructed them.
  640. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  641. % @asis just yields its argument.  Used with @table, for example.
  642. \def\asis#1{#1}
  643. % @math means output in math mode.
  644. % We don't use $'s directly in the definition of \math because control
  645. % sequences like \math are expanded when the toc file is written.  Then,
  646. % we read the toc file back, the $'s will be normal characters (as they
  647. % should be, according to the definition of Texinfo).  So we must use a
  648. % control sequence to switch into and out of math mode.
  649. % This isn't quite enough for @math to work properly in indices, but it
  650. % seems unlikely it will ever be needed there.
  651. \let\implicitmath = $
  652. \def\math#1{\implicitmath #1\implicitmath}
  653. % @bullet and @minus need the same treatment as @math, just above.
  654. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  655. \def\minus{\implicitmath-\implicitmath}
  656. \def\node{\ENVcheck\parsearg\nodezzz}
  657. \def\nodezzz#1{\nodexxx [#1,]}
  658. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  659. \let\nwnode=\node
  660. \let\lastnode=\relax
  661. \def\donoderef{\ifx\lastnode\relax\else
  662. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  663. \let\lastnode=\relax}
  664. \def\unnumbnoderef{\ifx\lastnode\relax\else
  665. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  666. \let\lastnode=\relax}
  667. \def\appendixnoderef{\ifx\lastnode\relax\else
  668. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  669. \let\lastnode=\relax}
  670. \let\refill=\relax
  671. % @setfilename is done at the beginning of every texinfo file.
  672. % So open here the files we need to have open while reading the input.
  673. % This makes it possible to make a .fmt file for texinfo.
  674. \def\setfilename{%
  675.    \readauxfile
  676.    \opencontents
  677.    \openindices
  678.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  679.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  680.    \comment % Ignore the actual filename.
  681. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  682. \def\inforef #1{\inforefzzz #1,,,,**}
  683. \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
  684.   node \samp{\ignorespaces#1{}}}
  685. \message{fonts,}
  686. % Font-change commands.
  687. % Texinfo supports the sans serif font style, which plain TeX does not.
  688. % So we set up a \sf analogous to plain's \rm, etc.
  689. \newfam\sffam
  690. \def\sf{\fam=\sffam \tensf}
  691. \let\li = \sf % Sometimes we call it \li, not \sf.
  692. %% Try out Computer Modern fonts at \magstephalf
  693. \let\mainmagstep=\magstephalf
  694. \ifx\bigger\relax
  695. \let\mainmagstep=\magstep1
  696. \font\textrm=cmr12
  697. \font\texttt=cmtt12
  698. \else
  699. \font\textrm=cmr10 scaled \mainmagstep
  700. \font\texttt=cmtt10 scaled \mainmagstep
  701. % Instead of cmb10, you many want to use cmbx10.
  702. % cmbx10 is a prettier font on its own, but cmb10
  703. % looks better when embedded in a line with cmr10.
  704. \font\textbf=cmb10 scaled \mainmagstep
  705. \font\textit=cmti10 scaled \mainmagstep
  706. \font\textsl=cmsl10 scaled \mainmagstep
  707. \font\textsf=cmss10 scaled \mainmagstep
  708. \font\textsc=cmcsc10 scaled \mainmagstep
  709. \font\texti=cmmi10 scaled \mainmagstep
  710. \font\textsy=cmsy10 scaled \mainmagstep
  711. % A few fonts for @defun, etc.
  712. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  713. \font\deftt=cmtt10 scaled \magstep1
  714. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  715. % Fonts for indices and small examples.
  716. % We actually use the slanted font rather than the italic,
  717. % because texinfo normally uses the slanted fonts for that.
  718. % Do not make many font distinctions in general in the index, since they
  719. % aren't very useful.
  720. \font\ninett=cmtt9
  721. \font\indrm=cmr9
  722. \font\indit=cmsl9
  723. \let\indsl=\indit
  724. \let\indtt=\ninett
  725. \let\indsf=\indrm
  726. \let\indbf=\indrm
  727. \let\indsc=\indrm
  728. \font\indi=cmmi9
  729. \font\indsy=cmsy9
  730. % Fonts for headings
  731. \font\chaprm=cmbx12 scaled \magstep2
  732. \font\chapit=cmti12 scaled \magstep2
  733. \font\chapsl=cmsl12 scaled \magstep2
  734. \font\chaptt=cmtt12 scaled \magstep2
  735. \font\chapsf=cmss12 scaled \magstep2
  736. \let\chapbf=\chaprm
  737. \font\chapsc=cmcsc10 scaled\magstep3
  738. \font\chapi=cmmi12 scaled \magstep2
  739. \font\chapsy=cmsy10 scaled \magstep3
  740. \font\secrm=cmbx12 scaled \magstep1
  741. \font\secit=cmti12 scaled \magstep1
  742. \font\secsl=cmsl12 scaled \magstep1
  743. \font\sectt=cmtt12 scaled \magstep1
  744. \font\secsf=cmss12 scaled \magstep1
  745. \font\secbf=cmbx12 scaled \magstep1
  746. \font\secsc=cmcsc10 scaled\magstep2
  747. \font\seci=cmmi12 scaled \magstep1
  748. \font\secsy=cmsy10 scaled \magstep2
  749. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  750. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  751. % \font\ssecsl=cmsl10 scaled \magstep1
  752. % \font\ssectt=cmtt10 scaled \magstep1
  753. % \font\ssecsf=cmss10 scaled \magstep1
  754. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  755. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  756. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  757. %\font\ssectt=cmtt10 scaled 1315
  758. %\font\ssecsf=cmss10 scaled 1315
  759. %\let\ssecbf=\ssecrm
  760. \font\ssecrm=cmbx12 scaled \magstephalf
  761. \font\ssecit=cmti12 scaled \magstephalf
  762. \font\ssecsl=cmsl12 scaled \magstephalf
  763. \font\ssectt=cmtt12 scaled \magstephalf
  764. \font\ssecsf=cmss12 scaled \magstephalf
  765. \font\ssecbf=cmbx12 scaled \magstephalf
  766. \font\ssecsc=cmcsc10 scaled \magstep1
  767. \font\sseci=cmmi12 scaled \magstephalf
  768. \font\ssecsy=cmsy10 scaled \magstep1
  769. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  770. % but that is not a standard magnification.
  771. % Fonts for title page:
  772. \font\titlerm = cmbx12 scaled \magstep3
  773. \let\authorrm = \secrm
  774. % In order for the font changes to affect most math symbols and letters,
  775. % we have to define the \textfont of the standard families.  Since
  776. % texinfo doesn't allow for producing subscripts and superscripts, we
  777. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  778. % also require loading a lot more fonts).
  779. \def\resetmathfonts{%
  780.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  781.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  782.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  783. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  784. % of just \STYLE.  We do this so that font changes will continue to work
  785. % in math mode, where it is the current \fam that is relevant in most
  786. % cases, not the current.  Plain TeX does, for example,
  787. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  788. % to redefine \bf itself.
  789. \def\textfonts{%
  790.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  791.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  792.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  793.   \resetmathfonts}
  794. \def\chapfonts{%
  795.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
  796.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  797.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  798.   \resetmathfonts}
  799. \def\secfonts{%
  800.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  801.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  802.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  803.   \resetmathfonts}
  804. \def\subsecfonts{%
  805.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  806.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  807.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  808.   \resetmathfonts}
  809. \def\indexfonts{%
  810.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  811.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  812.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  813.   \resetmathfonts}
  814. % Set up the default fonts, so we can use them for creating boxes.
  815. \textfonts
  816. % Count depth in font-changes, for error checks
  817. \newcount\fontdepth \fontdepth=0
  818. % Fonts for short table of contents.
  819. \font\shortcontrm=cmr12
  820. \font\shortcontbf=cmbx12
  821. \font\shortcontsl=cmsl12
  822. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  823. %% serif) and @ii for TeX italic
  824. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  825. % unless the following character is such as not to need one.
  826. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  827. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  828. \let\i=\smartitalic
  829. \let\var=\smartitalic
  830. \let\dfn=\smartitalic
  831. \let\emph=\smartitalic
  832. \let\cite=\smartitalic
  833. \def\b#1{{\bf #1}}
  834. \let\strong=\b
  835. % We can't just use \exhyphenpenalty, because that only has effect at
  836. % the end of a paragraph.  Restore normal hyphenation at the end of the
  837. % group within which \nohyphenation is presumably called.
  838. \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
  839. \def\restorehyphenation{\hyphenchar\font = `- }
  840. \def\t#1{%
  841.   {\tt \nohyphenation \rawbackslash \frenchspacing #1}%
  842.   \null
  843. \let\ttfont = \t
  844. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  845. \def\samp #1{`\tclose{#1}'\null}
  846. \def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
  847. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  848. \let\file=\samp
  849. % @code is a modification of @t,
  850. % which makes spaces the same size as normal in the surrounding text.
  851. \def\tclose#1{%
  852.     % Change normal interword space to be same as for the current font.
  853.     \spaceskip = \fontdimen2\font
  854.     %
  855.     % Switch to typewriter.
  856.     \tt
  857.     %
  858.     % But `\ ' produces the large typewriter interword space.
  859.     \def\ {{\spaceskip = 0pt{} }}%
  860.     %
  861.     % Turn off hyphenation.
  862.     \nohyphenation
  863.     %
  864.     \rawbackslash
  865.     \frenchspacing
  866.     #1%
  867.   \null
  868. % We *must* turn on hyphenation at `-' and `_' in \code.
  869. % Otherwise, it is too hard to avoid overful hboxes
  870. % in the Emacs manual, the Library manual, etc.
  871. % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  872. % both hyphenation at - and hyphenation within words.
  873. % We must therefore turn them both off (\tclose does that)
  874. % and arrange explicitly to hyphenate an a dash.
  875. %  -- rms.
  876. \catcode`\-=\active
  877. \catcode`\_=\active
  878. \global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex}
  879. % The following is used by \doprintindex to insure that long function names
  880. % wrap around.  It is necessary for - and _ to be active before the index is
  881. % read from the file, as \entry parses the arguments long before \code is
  882. % ever called.  -- mycroft
  883. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder}
  884. \def\realdash{-}
  885. \def\realunder{_}
  886. \def\codedash{-\discretionary{}{}{}}
  887. \def\codeunder{\normalunderscore\discretionary{}{}{}}
  888. \def\codex #1{\tclose{#1}\endgroup}
  889. %\let\exp=\tclose  %Was temporary
  890. % @kbd is like @code, except that if the argument is just one @key command,
  891. % then @kbd has no effect.
  892. \def\xkey{\key}
  893. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  894. \ifx\one\xkey\ifx\threex\three \key{#2}%
  895. \else\tclose{\look}\fi
  896. \else\tclose{\look}\fi}
  897. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  898. % argument is to make the input look right: @dmn{pt} instead of
  899. % @dmn{}pt.
  900. \def\dmn#1{\thinspace #1}
  901. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  902. \def\l#1{{\li #1}\null}        %
  903. \def\r#1{{\rm #1}}        % roman font
  904. % Use of \lowercase was suggested.
  905. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  906. \def\ii#1{{\it #1}}        % italic font
  907. \message{page headings,}
  908. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  909. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  910. % First the title page.  Must do @settitle before @titlepage.
  911. \def\titlefont#1{{\titlerm #1}}
  912. \newif\ifseenauthor
  913. \newif\iffinishedtitlepage
  914. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  915. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  916.     \endgroup\page\hbox{}\page}
  917. \def\titlepage{\begingroup \parindent=0pt \textfonts
  918.    \let\subtitlerm=\tenrm
  919. % I deinstalled the following change because \cmr12 is undefined.
  920. % This change was not in the ChangeLog anyway.  --rms.
  921. %   \let\subtitlerm=\cmr12
  922.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  923.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  924.    % Leave some space at the very top of the page.
  925.    \vglue\titlepagetopglue
  926.    % Now you can print the title using @title.
  927.    \def\title{\parsearg\titlezzz}%
  928.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  929.             % print a rule at the page bottom also.
  930.             \finishedtitlepagefalse
  931.             \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
  932.    % No rule at page bottom unless we print one at the top with @title.
  933.    \finishedtitlepagetrue
  934.    % Now you can put text using @subtitle.
  935.    \def\subtitle{\parsearg\subtitlezzz}%
  936.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  937.    % @author should come last, but may come many times.
  938.    \def\author{\parsearg\authorzzz}%
  939.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  940.       {\authorfont \leftline{##1}}}%
  941.    % Most title ``pages'' are actually two pages long, with space
  942.    % at the top of the second.  We don't want the ragged left on the second.
  943.    \let\oldpage = \page
  944.    \def\page{%
  945.       \iffinishedtitlepage\else
  946.      \finishtitlepage
  947.       \fi
  948.       \oldpage
  949.       \let\page = \oldpage
  950.       \hbox{}}%
  951. %   \def\page{\oldpage \hbox{}}
  952. \def\Etitlepage{%
  953.    \iffinishedtitlepage\else
  954.       \finishtitlepage
  955.    \fi
  956.    % It is important to do the page break before ending the group,
  957.    % because the headline and footline are only empty inside the group.
  958.    % If we use the new definition of \page, we always get a blank page
  959.    % after the title page, which we certainly don't want.
  960.    \oldpage
  961.    \endgroup
  962.    \HEADINGSon
  963. \def\finishtitlepage{%
  964.    \vskip4pt \hrule height 2pt width \hsize
  965.    \vskip\titlepagebottomglue
  966.    \finishedtitlepagetrue
  967. %%% Set up page headings and footings.
  968. \let\thispage=\folio
  969. \newtoks \evenheadline    % Token sequence for heading line of even pages
  970. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  971. \newtoks \evenfootline    % Token sequence for footing line of even pages
  972. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  973. % Now make Tex use those variables
  974. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  975.                             \else \the\evenheadline \fi}}
  976. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  977.                             \else \the\evenfootline \fi}\HEADINGShook}
  978. \let\HEADINGShook=\relax
  979. % Commands to set those variables.
  980. % For example, this is what  @headings on  does
  981. % @evenheading @thistitle|@thispage|@thischapter
  982. % @oddheading @thischapter|@thispage|@thistitle
  983. % @evenfooting @thisfile||
  984. % @oddfooting ||@thisfile
  985. \def\evenheading{\parsearg\evenheadingxxx}
  986. \def\oddheading{\parsearg\oddheadingxxx}
  987. \def\everyheading{\parsearg\everyheadingxxx}
  988. \def\evenfooting{\parsearg\evenfootingxxx}
  989. \def\oddfooting{\parsearg\oddfootingxxx}
  990. \def\everyfooting{\parsearg\everyfootingxxx}
  991. {\catcode`\@=0 %
  992. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  993. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  994. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  995. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  996. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  997. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  998. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  999. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  1000. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1001. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1002. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  1003. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  1004. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1005. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  1006. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  1007. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1008. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  1009. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  1010. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1011. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1012. }% unbind the catcode of @.
  1013. % @headings double    turns headings on for double-sided printing.
  1014. % @headings single    turns headings on for single-sided printing.
  1015. % @headings off        turns them off.
  1016. % @headings on        same as @headings double, retained for compatibility.
  1017. % @headings after    turns on double-sided headings after this page.
  1018. % @headings doubleafter    turns on double-sided headings after this page.
  1019. % @headings singleafter turns on single-sided headings after this page.
  1020. % By default, they are off.
  1021. \def\headings #1 {\csname HEADINGS#1\endcsname}
  1022. \def\HEADINGSoff{
  1023. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  1024. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  1025. \HEADINGSoff
  1026. % When we turn headings on, set the page number to 1.
  1027. % For double-sided printing, put current file name in lower left corner,
  1028. % chapter name on inside top of right hand pages, document
  1029. % title on inside top of left hand pages, and page numbers on outside top
  1030. % edge of all pages.
  1031. \def\HEADINGSdouble{
  1032. %\pagealignmacro
  1033. \global\pageno=1
  1034. \global\evenfootline={\hfil}
  1035. \global\oddfootline={\hfil}
  1036. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1037. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1038. % For single-sided printing, chapter title goes across top left of page,
  1039. % page number on top right.
  1040. \def\HEADINGSsingle{
  1041. %\pagealignmacro
  1042. \global\pageno=1
  1043. \global\evenfootline={\hfil}
  1044. \global\oddfootline={\hfil}
  1045. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1046. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1047. \def\HEADINGSon{\HEADINGSdouble}
  1048. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  1049. \let\HEADINGSdoubleafter=\HEADINGSafter
  1050. \def\HEADINGSdoublex{%
  1051. \global\evenfootline={\hfil}
  1052. \global\oddfootline={\hfil}
  1053. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1054. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1055. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  1056. \def\HEADINGSsinglex{%
  1057. \global\evenfootline={\hfil}
  1058. \global\oddfootline={\hfil}
  1059. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1060. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1061. % Subroutines used in generating headings
  1062. % Produces Day Month Year style of output.
  1063. \def\today{\number\day\space
  1064. \ifcase\month\or
  1065. January\or February\or March\or April\or May\or June\or
  1066. July\or August\or September\or October\or November\or December\fi
  1067. \space\number\year}
  1068. % Use this if you want the Month Day, Year style of output.
  1069. %\def\today{\ifcase\month\or
  1070. %January\or February\or March\or April\or May\or June\or
  1071. %July\or August\or September\or October\or November\or December\fi
  1072. %\space\number\day, \number\year}
  1073. % @settitle line...  specifies the title of the document, for headings
  1074. % It generates no output of its own
  1075. \def\thistitle{No Title}
  1076. \def\settitle{\parsearg\settitlezzz}
  1077. \def\settitlezzz #1{\gdef\thistitle{#1}}
  1078. \message{tables,}
  1079. % @tabs -- simple alignment
  1080. % These don't work.  For one thing, \+ is defined as outer.
  1081. % So these macros cannot even be defined.
  1082. %\def\tabs{\parsearg\tabszzz}
  1083. %\def\tabszzz #1{\settabs\+#1\cr}
  1084. %\def\tabline{\parsearg\tablinezzz}
  1085. %\def\tablinezzz #1{\+#1\cr}
  1086. %\def\&{&}
  1087. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  1088. % default indentation of table text
  1089. \newdimen\tableindent \tableindent=.8in
  1090. % default indentation of @itemize and @enumerate text
  1091. \newdimen\itemindent  \itemindent=.3in
  1092. % margin between end of table item and start of table text.
  1093. \newdimen\itemmargin  \itemmargin=.1in
  1094. % used internally for \itemindent minus \itemmargin
  1095. \newdimen\itemmax
  1096. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  1097. % these defs.
  1098. % They also define \itemindex
  1099. % to index the item name in whatever manner is desired (perhaps none).
  1100. \newif\ifitemxneedsnegativevskip
  1101. \def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi}
  1102. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  1103. \def\internalBitemx{\itemxpar \parsearg\itemzzz}
  1104. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  1105. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
  1106. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1107. \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
  1108. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1109.                  \itemzzz {#1}}
  1110. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1111.                  \itemzzz {#1}}
  1112. \def\itemzzz #1{\begingroup %
  1113.   \advance\hsize by -\rightskip
  1114.   \advance\hsize by -\tableindent
  1115.   \setbox0=\hbox{\itemfont{#1}}%
  1116.   \itemindex{#1}%
  1117.   \nobreak % This prevents a break before @itemx.
  1118.   % Be sure we are not still in the middle of a paragraph.
  1119.   %{\parskip = 0in
  1120.   %\par
  1121.   %}%
  1122.   % If the item text does not fit in the space we have, put it on a line
  1123.   % by itself, and do not allow a page break either before or after that
  1124.   % line.  We do not start a paragraph here because then if the next
  1125.   % command is, e.g., @kindex, the whatsit would get put into the
  1126.   % horizontal list on a line by itself, resulting in extra blank space.
  1127.   \ifdim \wd0>\itemmax
  1128.     %
  1129.     % Make this a paragraph so we get the \parskip glue and wrapping,
  1130.     % but leave it ragged-right.
  1131.     \begingroup
  1132.       \advance\leftskip by-\tableindent
  1133.       \advance\hsize by\tableindent
  1134.       \advance\rightskip by0pt plus1fil
  1135.       \leavevmode\unhbox0\par
  1136.     \endgroup
  1137.     %
  1138.     % We're going to be starting a paragraph, but we don't want the
  1139.     % \parskip glue -- logically it's part of the @item we just started.
  1140.     \nobreak \vskip-\parskip
  1141.     %
  1142.     % Stop a page break at the \parskip glue coming up.  Unfortunately
  1143.     % we can't prevent a possible page break at the following
  1144.     % \baselineskip glue.
  1145.     \nobreak
  1146.     \endgroup
  1147.     \itemxneedsnegativevskipfalse
  1148.   \else
  1149.     % The item text fits into the space.  Start a paragraph, so that the
  1150.     % following text (if any) will end up on the same line.  Since that
  1151.     % text will be indented by \tableindent, we make the item text be in
  1152.     % a zero-width box.
  1153.     \noindent
  1154.     \rlap{\hskip -\tableindent\box0}\ignorespaces%
  1155.     \endgroup%
  1156.     \itemxneedsnegativevskiptrue%
  1157.   \fi
  1158. \def\item{\errmessage{@item while not in a table}}
  1159. \def\itemx{\errmessage{@itemx while not in a table}}
  1160. \def\kitem{\errmessage{@kitem while not in a table}}
  1161. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1162. \def\xitem{\errmessage{@xitem while not in a table}}
  1163. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1164. %% Contains a kludge to get @end[description] to work
  1165. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1166. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1167. {\obeylines\obeyspaces%
  1168. \gdef\tablex #1^^M{%
  1169. \tabley\dontindex#1        \endtabley}}
  1170. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1171. {\obeylines\obeyspaces%
  1172. \gdef\ftablex #1^^M{%
  1173. \tabley\fnitemindex#1        \endtabley
  1174. \def\Eftable{\endgraf\afterenvbreak\endgroup}%
  1175. \let\Etable=\relax}}
  1176. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1177. {\obeylines\obeyspaces%
  1178. \gdef\vtablex #1^^M{%
  1179. \tabley\vritemindex#1        \endtabley
  1180. \def\Evtable{\endgraf\afterenvbreak\endgroup}%
  1181. \let\Etable=\relax}}
  1182. \def\dontindex #1{}
  1183. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1184. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1185. {\obeyspaces %
  1186. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1187. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1188. \def\tablez #1#2#3#4#5#6{%
  1189. \aboveenvbreak %
  1190. \begingroup %
  1191. \def\Edescription{\Etable}% Neccessary kludge.
  1192. \let\itemindex=#1%
  1193. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1194. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1195. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1196. \def\itemfont{#2}%
  1197. \itemmax=\tableindent %
  1198. \advance \itemmax by -\itemmargin %
  1199. \advance \leftskip by \tableindent %
  1200. \exdentamount=\tableindent
  1201. \parindent = 0pt
  1202. \parskip = \smallskipamount
  1203. \ifdim \parskip=0pt \parskip=2pt \fi%
  1204. \def\Etable{\endgraf\afterenvbreak\endgroup}%
  1205. \let\item = \internalBitem %
  1206. \let\itemx = \internalBitemx %
  1207. \let\kitem = \internalBkitem %
  1208. \let\kitemx = \internalBkitemx %
  1209. \let\xitem = \internalBxitem %
  1210. \let\xitemx = \internalBxitemx %
  1211. % This is the counter used by @enumerate, which is really @itemize
  1212. \newcount \itemno
  1213. \def\itemize{\parsearg\itemizezzz}
  1214. \def\itemizezzz #1{%
  1215.   \begingroup % ended by the @end itemsize
  1216.   \itemizey {#1}{\Eitemize}
  1217. \def\itemizey #1#2{%
  1218. \aboveenvbreak %
  1219. \itemmax=\itemindent %
  1220. \advance \itemmax by -\itemmargin %
  1221. \advance \leftskip by \itemindent %
  1222. \exdentamount=\itemindent
  1223. \parindent = 0pt %
  1224. \parskip = \smallskipamount %
  1225. \ifdim \parskip=0pt \parskip=2pt \fi%
  1226. \def#2{\endgraf\afterenvbreak\endgroup}%
  1227. \def\itemcontents{#1}%
  1228. \let\item=\itemizeitem}
  1229. % Set sfcode to normal for the chars that usually have another value.
  1230. % These are `.?!:;,'
  1231. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1232.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1233. % \splitoff TOKENS\endmark defines \first to be the first token in
  1234. % TOKENS, and \rest to be the remainder.
  1235. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1236. % Allow an optional argument of an uppercase letter, lowercase letter,
  1237. % or number, to specify the first label in the enumerated list.  No
  1238. % argument is the same as `1'.
  1239. \def\enumerate{\parsearg\enumeratezzz}
  1240. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1241. \def\enumeratey #1 #2\endenumeratey{%
  1242.   \begingroup % ended by the @end enumerate
  1243.   % If we were given no argument, pretend we were given `1'.
  1244.   \def\thearg{#1}%
  1245.   \ifx\thearg\empty \def\thearg{1}\fi
  1246.   % Detect if the argument is a single token.  If so, it might be a
  1247.   % letter.  Otherwise, the only valid thing it can be is a number.
  1248.   % (We will always have one token, because of the test we just made.
  1249.   % This is a good thing, since \splitoff doesn't work given nothing at
  1250.   % all -- the first parameter is undelimited.)
  1251.   \expandafter\splitoff\thearg\endmark
  1252.   \ifx\rest\empty
  1253.     % Only one token in the argument.  It could still be anything.
  1254.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1255.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1256.     %   not equal to itself.
  1257.     % Otherwise, we assume it's a number.
  1258.     %
  1259.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1260.     % continuing to look for a <number>.
  1261.     %
  1262.     \ifnum\lccode\expandafter`\thearg=0\relax
  1263.       \numericenumerate % a number (we hope)
  1264.     \else
  1265.       % It's a letter.
  1266.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1267.         \lowercaseenumerate % lowercase letter
  1268.       \else
  1269.         \uppercaseenumerate % uppercase letter
  1270.       \fi
  1271.     \fi
  1272.   \else
  1273.     % Multiple tokens in the argument.  We hope it's a number.
  1274.     \numericenumerate
  1275.   \fi
  1276. % An @enumerate whose labels are integers.  The starting integer is
  1277. % given in \thearg.
  1278. \def\numericenumerate{%
  1279.   \itemno = \thearg
  1280.   \startenumeration{\the\itemno}%
  1281. % The starting (lowercase) letter is in \thearg.
  1282. \def\lowercaseenumerate{%
  1283.   \itemno = \expandafter`\thearg
  1284.   \startenumeration{%
  1285.     % Be sure we're not beyond the end of the alphabet.
  1286.     \ifnum\itemno=0
  1287.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1288.                   alphabet}%
  1289.     \fi
  1290.     \char\lccode\itemno
  1291. % The starting (uppercase) letter is in \thearg.
  1292. \def\uppercaseenumerate{%
  1293.   \itemno = \expandafter`\thearg
  1294.   \startenumeration{%
  1295.     % Be sure we're not beyond the end of the alphabet.
  1296.     \ifnum\itemno=0
  1297.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1298.                   alphabet}
  1299.     \fi
  1300.     \char\uccode\itemno
  1301. % Call itemizey, adding a period to the first argument and supplying the
  1302. % common last two arguments.  Also subtract one from the initial value in
  1303. % \itemno, since @item increments \itemno.
  1304. \def\startenumeration#1{%
  1305.   \advance\itemno by -1
  1306.   \itemizey{#1.}\Eenumerate\flushcr
  1307. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1308. % to @enumerate.
  1309. \def\alphaenumerate{\enumerate{a}}
  1310. \def\capsenumerate{\enumerate{A}}
  1311. \def\Ealphaenumerate{\Eenumerate}
  1312. \def\Ecapsenumerate{\Eenumerate}
  1313. % Definition of @item while inside @itemize.
  1314. \def\itemizeitem{%
  1315. \advance\itemno by 1
  1316. {\let\par=\endgraf \smallbreak}%
  1317. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1318. {\parskip=0in \hskip 0pt
  1319. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1320. \vadjust{\penalty 1200}}%
  1321. \flushcr}
  1322. \message{indexing,}
  1323. % Index generation facilities
  1324. % Define \newwrite to be identical to plain tex's \newwrite
  1325. % except not \outer, so it can be used within \newindex.
  1326. {\catcode`\@=11
  1327. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1328. % \newindex {foo} defines an index named foo.
  1329. % It automatically defines \fooindex such that
  1330. % \fooindex ...rest of line... puts an entry in the index foo.
  1331. % It also defines \fooindfile to be the number of the output channel for
  1332. % the file that    accumulates this index.  The file's extension is foo.
  1333. % The name of an index should be no more than 2 characters long
  1334. % for the sake of vms.
  1335. \def\newindex #1{
  1336. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1337. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1338. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1339. \noexpand\doindex {#1}}
  1340. % @defindex foo  ==  \newindex{foo}
  1341. \def\defindex{\parsearg\newindex}
  1342. % Define @defcodeindex, like @defindex except put all entries in @code.
  1343. \def\newcodeindex #1{
  1344. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1345. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1346. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1347. \noexpand\docodeindex {#1}}
  1348. \def\defcodeindex{\parsearg\newcodeindex}
  1349. % @synindex foo bar    makes index foo feed into index bar.
  1350. % Do this instead of @defindex foo if you don't want it as a separate index.
  1351. \def\synindex #1 #2 {%
  1352. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1353. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1354. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1355. \noexpand\doindex {#2}}%
  1356. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1357. % inside @code.
  1358. \def\syncodeindex #1 #2 {%
  1359. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1360. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1361. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1362. \noexpand\docodeindex {#2}}%
  1363. % Define \doindex, the driver for all \fooindex macros.
  1364. % Argument #1 is generated by the calling \fooindex macro,
  1365. %  and it is "foo", the name of the index.
  1366. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1367. % This is because \doind is more useful to call from other macros.
  1368. % There is also \dosubind {index}{topic}{subtopic}
  1369. % which makes an entry in a two-level index such as the operation index.
  1370. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1371. \def\singleindexer #1{\doind{\indexname}{#1}}
  1372. % like the previous two, but they put @code around the argument.
  1373. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1374. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1375. \def\indexdummies{%
  1376. % Take care of the plain tex accent commands.
  1377. \def\"{\realbackslash "}%
  1378. \def\`{\realbackslash `}%
  1379. \def\'{\realbackslash '}%
  1380. \def\^{\realbackslash ^}%
  1381. \def\~{\realbackslash ~}%
  1382. \def\={\realbackslash =}%
  1383. \def\b{\realbackslash b}%
  1384. \def\c{\realbackslash c}%
  1385. \def\d{\realbackslash d}%
  1386. \def\u{\realbackslash u}%
  1387. \def\v{\realbackslash v}%
  1388. \def\H{\realbackslash H}%
  1389. % Take care of the plain tex special European modified letters.
  1390. \def\oe{\realbackslash oe}%
  1391. \def\ae{\realbackslash ae}%
  1392. \def\aa{\realbackslash aa}%
  1393. \def\OE{\realbackslash OE}%
  1394. \def\AE{\realbackslash AE}%
  1395. \def\AA{\realbackslash AA}%
  1396. \def\o{\realbackslash o}%
  1397. \def\O{\realbackslash O}%
  1398. \def\l{\realbackslash l}%
  1399. \def\L{\realbackslash L}%
  1400. \def\ss{\realbackslash ss}%
  1401. % Take care of texinfo commands likely to appear in an index entry.
  1402. \def\_{{\realbackslash _}}%
  1403. \def\w{\realbackslash w }%
  1404. \def\bf{\realbackslash bf }%
  1405. \def\rm{\realbackslash rm }%
  1406. \def\sl{\realbackslash sl }%
  1407. \def\sf{\realbackslash sf}%
  1408. \def\tt{\realbackslash tt}%
  1409. \def\gtr{\realbackslash gtr}%
  1410. \def\less{\realbackslash less}%
  1411. \def\hat{\realbackslash hat}%
  1412. \def\char{\realbackslash char}%
  1413. \def\TeX{\realbackslash TeX}%
  1414. \def\dots{\realbackslash dots }%
  1415. \def\copyright{\realbackslash copyright }%
  1416. \def\tclose##1{\realbackslash tclose {##1}}%
  1417. \def\code##1{\realbackslash code {##1}}%
  1418. \def\samp##1{\realbackslash samp {##1}}%
  1419. \def\t##1{\realbackslash r {##1}}%
  1420. \def\r##1{\realbackslash r {##1}}%
  1421. \def\i##1{\realbackslash i {##1}}%
  1422. \def\b##1{\realbackslash b {##1}}%
  1423. \def\cite##1{\realbackslash cite {##1}}%
  1424. \def\key##1{\realbackslash key {##1}}%
  1425. \def\file##1{\realbackslash file {##1}}%
  1426. \def\var##1{\realbackslash var {##1}}%
  1427. \def\kbd##1{\realbackslash kbd {##1}}%
  1428. \def\dfn##1{\realbackslash dfn {##1}}%
  1429. \def\emph##1{\realbackslash emph {##1}}%
  1430. % \indexnofonts no-ops all font-change commands.
  1431. % This is used when outputting the strings to sort the index by.
  1432. \def\indexdummyfont#1{#1}
  1433. \def\indexdummytex{TeX}
  1434. \def\indexdummydots{...}
  1435. \def\indexnofonts{%
  1436. % Just ignore accents.
  1437. \let\"=\indexdummyfont
  1438. \let\`=\indexdummyfont
  1439. \let\'=\indexdummyfont
  1440. \let\^=\indexdummyfont
  1441. \let\~=\indexdummyfont
  1442. \let\==\indexdummyfont
  1443. \let\b=\indexdummyfont
  1444. \let\c=\indexdummyfont
  1445. \let\d=\indexdummyfont
  1446. \let\u=\indexdummyfont
  1447. \let\v=\indexdummyfont
  1448. \let\H=\indexdummyfont
  1449. % Take care of the plain tex special European modified letters.
  1450. \def\oe{oe}%
  1451. \def\ae{ae}%
  1452. \def\aa{aa}%
  1453. \def\OE{OE}%
  1454. \def\AE{AE}%
  1455. \def\AA{AA}%
  1456. \def\o{o}%
  1457. \def\O{O}%
  1458. \def\l{l}%
  1459. \def\L{L}%
  1460. \def\ss{ss}%
  1461. \let\w=\indexdummyfont
  1462. \let\t=\indexdummyfont
  1463. \let\r=\indexdummyfont
  1464. \let\i=\indexdummyfont
  1465. \let\b=\indexdummyfont
  1466. \let\emph=\indexdummyfont
  1467. \let\strong=\indexdummyfont
  1468. \let\cite=\indexdummyfont
  1469. \let\sc=\indexdummyfont
  1470. %Don't no-op \tt, since it isn't a user-level command
  1471. % and is used in the definitions of the active chars like <, >, |...
  1472. %\let\tt=\indexdummyfont
  1473. \let\tclose=\indexdummyfont
  1474. \let\code=\indexdummyfont
  1475. \let\file=\indexdummyfont
  1476. \let\samp=\indexdummyfont
  1477. \let\kbd=\indexdummyfont
  1478. \let\key=\indexdummyfont
  1479. \let\var=\indexdummyfont
  1480. \let\TeX=\indexdummytex
  1481. \let\dots=\indexdummydots
  1482. % To define \realbackslash, we must make \ not be an escape.
  1483. % We must first make another character (@) an escape
  1484. % so we do not become unable to do a definition.
  1485. {\catcode`\@=0 \catcode`\\=\other
  1486. @gdef@realbackslash{\}}
  1487. \let\indexbackslash=0  %overridden during \printindex.
  1488. \def\doind #1#2{%
  1489. {\count10=\lastpenalty %
  1490. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1491. \escapechar=`\\%
  1492. {\let\folio=0% Expand all macros now EXCEPT \folio
  1493. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1494. % so it will be output as is; and it will print as backslash in the indx.
  1495. % Now process the index-string once, with all font commands turned off,
  1496. % to get the string to sort the index by.
  1497. {\indexnofonts
  1498. \xdef\temp1{#2}%
  1499. % Now produce the complete index entry.  We process the index-string again,
  1500. % this time with font commands expanded, to get what to print in the index.
  1501. \edef\temp{%
  1502. \write \csname#1indfile\endcsname{%
  1503. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1504. \temp }%
  1505. }\penalty\count10}}
  1506. \def\dosubind #1#2#3{%
  1507. {\count10=\lastpenalty %
  1508. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1509. \escapechar=`\\%
  1510. {\let\folio=0%
  1511. \def\rawbackslashxx{\indexbackslash}%
  1512. % Now process the index-string once, with all font commands turned off,
  1513. % to get the string to sort the index by.
  1514. {\indexnofonts
  1515. \xdef\temp1{#2 #3}%
  1516. % Now produce the complete index entry.  We process the index-string again,
  1517. % this time with font commands expanded, to get what to print in the index.
  1518. \edef\temp{%
  1519. \write \csname#1indfile\endcsname{%
  1520. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1521. \temp }%
  1522. }\penalty\count10}}
  1523. % The index entry written in the file actually looks like
  1524. %  \entry {sortstring}{page}{topic}
  1525. %  \entry {sortstring}{page}{topic}{subtopic}
  1526. % The texindex program reads in these files and writes files
  1527. % containing these kinds of lines:
  1528. %  \initial {c}
  1529. %     before the first topic whose initial is c
  1530. %  \entry {topic}{pagelist}
  1531. %     for a topic that is used without subtopics
  1532. %  \primary {topic}
  1533. %     for the beginning of a topic that is used with subtopics
  1534. %  \secondary {subtopic}{pagelist}
  1535. %     for each subtopic.
  1536. % Define the user-accessible indexing commands
  1537. % @findex, @vindex, @kindex, @cindex.
  1538. \def\findex {\fnindex}
  1539. \def\kindex {\kyindex}
  1540. \def\cindex {\cpindex}
  1541. \def\vindex {\vrindex}
  1542. \def\tindex {\tpindex}
  1543. \def\pindex {\pgindex}
  1544. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1545. {\obeylines %
  1546. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1547. \dosubind{cp}{#2}{#1}}}
  1548. % Define the macros used in formatting output of the sorted index material.
  1549. % This is what you call to cause a particular index to get printed.
  1550. % Write
  1551. % @unnumbered Function Index
  1552. % @printindex fn
  1553. \def\printindex{\parsearg\doprintindex}
  1554. \def\doprintindex#1{%
  1555.   \tex
  1556.   \dobreak \chapheadingskip {10000}
  1557.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1558.   \catcode`\$=\other
  1559.   \catcode`\~=\other
  1560.   \indexbreaks
  1561.   % The following don't help, since the chars were translated
  1562.   % when the raw index was written, and their fonts were discarded
  1563.   % due to \indexnofonts.
  1564.   %\catcode`\"=\active
  1565.   %\catcode`\^=\active
  1566.   %\catcode`\_=\active
  1567.   %\catcode`\|=\active
  1568.   %\catcode`\<=\active
  1569.   %\catcode`\>=\active
  1570.   % %
  1571.   \def\indexbackslash{\rawbackslashxx}
  1572.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1573.   \begindoublecolumns
  1574.   % See if the index file exists and is nonempty.
  1575.   \openin 1 \jobname.#1s
  1576.   \ifeof 1
  1577.     % \enddoublecolumns gets confused if there is no text in the index,
  1578.     % and it loses the chapter title and the aux file entries for the
  1579.     % index.  The easiest way to prevent this problem is to make sure
  1580.     % there is some text.
  1581.     (Index is nonexistent)
  1582.     \else
  1583.     %
  1584.     % If the index file exists but is empty, then \openin leaves \ifeof
  1585.     % false.  We have to make TeX try to read something from the file, so
  1586.     % it can discover if there is anything in it.
  1587.     \read 1 to \temp
  1588.     \ifeof 1
  1589.       (Index is empty)
  1590.     \else
  1591.       \input \jobname.#1s
  1592.     \fi
  1593.   \fi
  1594.   \closein 1
  1595.   \enddoublecolumns
  1596.   \Etex
  1597. % These macros are used by the sorted index file itself.
  1598. % Change them to control the appearance of the index.
  1599. % Same as \bigskipamount except no shrink.
  1600. % \balancecolumns gets confused if there is any shrink.
  1601. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1602. \def\initial #1{%
  1603. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1604. \ifdim\lastskip<\initialskipamount
  1605. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1606. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1607. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  1608. % flush to the right margin.  It is used for index and table of contents
  1609. % entries.  The paragraph is indented by \leftskip.
  1610. \def\entry #1#2{\begingroup
  1611.   % Start a new paragraph if necessary, so our assignments below can't
  1612.   % affect previous text.
  1613.   \par
  1614.   % Do not fill out the last line with white space.
  1615.   \parfillskip = 0in
  1616.   % No extra space above this paragraph.
  1617.   \parskip = 0in
  1618.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1619.   \finalhyphendemerits = 0
  1620.   % \hangindent is only relevant when the entry text and page number
  1621.   % don't both fit on one line.  In that case, bob suggests starting the
  1622.   % dots pretty far over on the line.  Unfortunately, a large
  1623.   % indentation looks wrong when the entry text itself is broken across
  1624.   % lines.  So we use a small indentation and put up with long leaders.
  1625.   % \hangafter is reset to 1 (which is the value we want) at the start
  1626.   % of each paragraph, so we need not do anything with that.
  1627.   \hangindent=2em
  1628.   % When the entry text needs to be broken, just fill out the first line
  1629.   % with blank space.
  1630.   \rightskip = 0pt plus1fil
  1631.   % Start a ``paragraph'' for the index entry so the line breaking
  1632.   % parameters we've set above will have an effect.
  1633.   \noindent
  1634.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1635.   #1%
  1636.   % The following is kluged to not output a line of dots in the index if
  1637.   % there are no page numbers.  The next person who breaks this will be
  1638.   % cursed by a Unix daemon.
  1639.   \def\tempa{{\rm }}%
  1640.   \def\tempb{#2}%
  1641.   \edef\tempc{\tempa}%
  1642.   \edef\tempd{\tempb}%
  1643.   \ifx\tempc\tempd\ \else%
  1644.     %
  1645.     % If we must, put the page number on a line of its own, and fill out
  1646.     % this line with blank space.  (The \hfil is overwhelmed with the
  1647.     % fill leaders glue in \indexdotfill if the page number does fit.)
  1648.     \hfil\penalty50
  1649.     \null\nobreak\indexdotfill % Have leaders before the page number.
  1650.     %
  1651.     % The `\ ' here is removed by the implicit \unskip that TeX does as
  1652.     % part of (the primitive) \par.  Without it, a spurious underfull
  1653.     % \hbox ensues.
  1654.     \ #2% The page number ends the paragraph.
  1655.   \fi%
  1656.   \par
  1657. \endgroup}
  1658. % Like \dotfill except takes at least 1 em.
  1659. \def\indexdotfill{\cleaders
  1660.   \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
  1661. \def\primary #1{\line{#1\hfil}}
  1662. \newskip\secondaryindent \secondaryindent=0.5cm
  1663. \def\secondary #1#2{
  1664. {\parfillskip=0in \parskip=0in
  1665. \hangindent =1in \hangafter=1
  1666. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1667. %% Define two-column mode, which is used in indexes.
  1668. %% Adapted from the TeXbook, page 416.
  1669. \catcode `\@=11
  1670. \newbox\partialpage
  1671. \newdimen\doublecolumnhsize
  1672. \def\begindoublecolumns{\begingroup
  1673.   % Grab any single-column material above us.
  1674.   \output = {\global\setbox\partialpage
  1675.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  1676.   \eject
  1677.   % Now switch to the double-column output routine.
  1678.   \output={\doublecolumnout}%
  1679.   % Change the page size parameters.  We could do this once outside this
  1680.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  1681.   % format, but then we repeat the same computation.  Repeating a couple
  1682.   % of assignments once per index is clearly meaningless for the
  1683.   % execution time, so we may as well do it once.
  1684.   % First we halve the line length, less a little for the gutter between
  1685.   % the columns.  We compute the gutter based on the line length, so it
  1686.   % changes automatically with the paper format.  The magic constant
  1687.   % below is chosen so that the gutter has the same value (well, +- <
  1688.   % 1pt) as it did when we hard-coded it.
  1689.   % We put the result in a separate register, \doublecolumhsize, so we
  1690.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  1691.   % been clobbered.
  1692.   \doublecolumnhsize = \hsize
  1693.     \advance\doublecolumnhsize by -.04154\hsize
  1694.     \divide\doublecolumnhsize by 2
  1695.   \hsize = \doublecolumnhsize
  1696.   % Double the \vsize as well.  (We don't need a separate register here,
  1697.   % since nobody clobbers \vsize.)
  1698.   \vsize = 2\vsize
  1699.   \doublecolumnpagegoal
  1700. \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
  1701. \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1702.   \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
  1703.   \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
  1704.   \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
  1705.   \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1706.   \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1707. \def\doublecolumnpagegoal{%
  1708.   \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
  1709. \def\pagesofar{\unvbox\partialpage %
  1710.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1711.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1712. \def\doublecolumnout{%
  1713.   \setbox5=\copy255
  1714.   {\vbadness=10000 \doublecolumnsplit}
  1715.   \ifvbox255
  1716.     \setbox0=\vtop to\dimen@{\unvbox0}
  1717.     \setbox2=\vtop to\dimen@{\unvbox2}
  1718.     \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
  1719.   \else
  1720.     \setbox0=\vbox{\unvbox5}
  1721.     \ifvbox0
  1722.       \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1723.       \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1724.       {\vbadness=10000
  1725.     \loop \global\setbox5=\copy0
  1726.           \setbox1=\vsplit5 to\dimen@
  1727.           \setbox3=\vsplit5 to\dimen@
  1728.           \ifvbox5 \global\advance\dimen@ by1pt \repeat
  1729.         \setbox0=\vbox to\dimen@{\unvbox1}
  1730.         \setbox2=\vbox to\dimen@{\unvbox3}
  1731.         \global\setbox\partialpage=\vbox{\pagesofar}
  1732.         \doublecolumnpagegoal
  1733.       }
  1734.     \fi
  1735.   \fi
  1736. \catcode `\@=\other
  1737. \message{sectioning,}
  1738. % Define chapters, sections, etc.
  1739. \newcount \chapno
  1740. \newcount \secno        \secno=0
  1741. \newcount \subsecno     \subsecno=0
  1742. \newcount \subsubsecno  \subsubsecno=0
  1743. % This counter is funny since it counts through charcodes of letters A, B, ...
  1744. \newcount \appendixno  \appendixno = `\@
  1745. \def\appendixletter{\char\the\appendixno}
  1746. \newwrite \contentsfile
  1747. % This is called from \setfilename.
  1748. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1749. % Each @chapter defines this as the name of the chapter.
  1750. % page headings and footings can use it.  @section does likewise
  1751. \def\thischapter{} \def\thissection{}
  1752. \def\seccheck#1{\if \pageno<0 %
  1753. \errmessage{@#1 not allowed after generating table of contents}\fi
  1754. \def\chapternofonts{%
  1755. \let\rawbackslash=\relax%
  1756. \let\frenchspacing=\relax%
  1757. \def\result{\realbackslash result}
  1758. \def\equiv{\realbackslash equiv}
  1759. \def\expansion{\realbackslash expansion}
  1760. \def\print{\realbackslash print}
  1761. \def\TeX{\realbackslash TeX}
  1762. \def\dots{\realbackslash dots}
  1763. \def\copyright{\realbackslash copyright}
  1764. \def\tt{\realbackslash tt}
  1765. \def\bf{\realbackslash bf }
  1766. \def\w{\realbackslash w}
  1767. \def\less{\realbackslash less}
  1768. \def\gtr{\realbackslash gtr}
  1769. \def\hat{\realbackslash hat}
  1770. \def\char{\realbackslash char}
  1771. \def\tclose##1{\realbackslash tclose {##1}}
  1772. \def\code##1{\realbackslash code {##1}}
  1773. \def\samp##1{\realbackslash samp {##1}}
  1774. \def\r##1{\realbackslash r {##1}}
  1775. \def\b##1{\realbackslash b {##1}}
  1776. \def\key##1{\realbackslash key {##1}}
  1777. \def\file##1{\realbackslash file {##1}}
  1778. \def\kbd##1{\realbackslash kbd {##1}}
  1779. % These are redefined because @smartitalic wouldn't work inside xdef.
  1780. \def\i##1{\realbackslash i {##1}}
  1781. \def\cite##1{\realbackslash cite {##1}}
  1782. \def\var##1{\realbackslash var {##1}}
  1783. \def\emph##1{\realbackslash emph {##1}}
  1784. \def\dfn##1{\realbackslash dfn {##1}}
  1785. \newcount\absseclevel % used to calculate proper heading level
  1786. \newcount\secbase\secbase=0 % @raise/lowersections modify this count
  1787. % @raisesections: treat @section as chapter, @subsection as section, etc.
  1788. \def\raisesections{\global\advance\secbase by -1}
  1789. \let\up=\raisesections % original BFox name
  1790. % @lowersections: treat @chapter as section, @section as subsection, etc.
  1791. \def\lowersections{\global\advance\secbase by 1}
  1792. \let\down=\lowersections % original BFox name
  1793. % Choose a numbered-heading macro
  1794. % #1 is heading level if unmodified by @raisesections or @lowersections
  1795. % #2 is text for heading
  1796. \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  1797. \ifcase\absseclevel
  1798.   \chapterzzz{#2}
  1799.   \seczzz{#2}
  1800.   \numberedsubseczzz{#2}
  1801.   \numberedsubsubseczzz{#2}
  1802. \else
  1803.   \ifnum \absseclevel<0
  1804.     \chapterzzz{#2}
  1805.   \else
  1806.     \numberedsubsubseczzz{#2}
  1807.   \fi
  1808. % like \numhead, but chooses appendix heading levels
  1809. \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  1810. \ifcase\absseclevel
  1811.   \appendixzzz{#2}
  1812.   \appendixsectionzzz{#2}
  1813.   \appendixsubseczzz{#2}
  1814.   \appendixsubsubseczzz{#2}
  1815. \else
  1816.   \ifnum \absseclevel<0
  1817.     \appendixzzz{#2}
  1818.   \else
  1819.     \appendixsubsubseczzz{#2}
  1820.   \fi
  1821. % like \numhead, but chooses numberless heading levels
  1822. \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  1823. \ifcase\absseclevel
  1824.   \unnumberedzzz{#2}
  1825.   \unnumberedseczzz{#2}
  1826.   \unnumberedsubseczzz{#2}
  1827.   \unnumberedsubsubseczzz{#2}
  1828. \else
  1829.   \ifnum \absseclevel<0
  1830.     \unnumberedzzz{#2}
  1831.   \else
  1832.     \unnumberedsubsubseczzz{#2}
  1833.   \fi
  1834. \def\thischaptername{No Chapter Title}
  1835. \outer\def\chapter{\parsearg\chapteryyy}
  1836. \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
  1837. \def\chapterzzz #1{\seccheck{chapter}%
  1838. \secno=0 \subsecno=0 \subsubsecno=0
  1839. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1840. \chapmacro {#1}{\the\chapno}%
  1841. \gdef\thissection{#1}%
  1842. \gdef\thischaptername{#1}%
  1843. % We don't substitute the actual chapter name into \thischapter
  1844. % because we don't want its macros evaluated now.
  1845. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
  1846. {\chapternofonts%
  1847. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1848. \escapechar=`\\%
  1849. \write \contentsfile \temp  %
  1850. \donoderef %
  1851. \global\let\section = \numberedsec
  1852. \global\let\subsection = \numberedsubsec
  1853. \global\let\subsubsection = \numberedsubsubsec
  1854. \outer\def\appendix{\parsearg\appendixyyy}
  1855. \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
  1856. \def\appendixzzz #1{\seccheck{appendix}%
  1857. \secno=0 \subsecno=0 \subsubsecno=0
  1858. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1859. \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
  1860. \gdef\thissection{#1}%
  1861. \gdef\thischaptername{#1}%
  1862. \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
  1863. {\chapternofonts%
  1864. \edef\temp{{\realbackslash chapentry
  1865.   {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}%
  1866. \escapechar=`\\%
  1867. \write \contentsfile \temp  %
  1868. \appendixnoderef %
  1869. \global\let\section = \appendixsec
  1870. \global\let\subsection = \appendixsubsec
  1871. \global\let\subsubsection = \appendixsubsubsec
  1872. \outer\def\top{\parsearg\unnumberedyyy}
  1873. \outer\def\unnumbered{\parsearg\unnumberedyyy}
  1874. \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  1875. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1876. \secno=0 \subsecno=0 \subsubsecno=0
  1877. % This used to be simply \message{#1}, but TeX fully expands the
  1878. % argument to \message.  Therefore, if #1 contained @-commands, TeX
  1879. % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
  1880. % expanded @cite (which turns out to cause errors because \cite is meant
  1881. % to be executed, not expanded).
  1882. % Anyway, we don't want the fully-expanded definition of @cite to appear
  1883. % as a result of the \message, we just want `@cite' itself.  We use
  1884. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  1885. % simply yielding the contents of the <toks register>.
  1886. \toks0 = {#1}\message{(\the\toks0)}%
  1887. \unnumbchapmacro {#1}%
  1888. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1889. {\chapternofonts%
  1890. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1891. \escapechar=`\\%
  1892. \write \contentsfile \temp  %
  1893. \unnumbnoderef %
  1894. \global\let\section = \unnumberedsec
  1895. \global\let\subsection = \unnumberedsubsec
  1896. \global\let\subsubsection = \unnumberedsubsubsec
  1897. \outer\def\numberedsec{\parsearg\secyyy}
  1898. \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
  1899. \def\seczzz #1{\seccheck{section}%
  1900. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1901. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1902. {\chapternofonts%
  1903. \edef\temp{{\realbackslash secentry %
  1904. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1905. \escapechar=`\\%
  1906. \write \contentsfile \temp %
  1907. \donoderef %
  1908. \penalty 10000 %
  1909. \outer\def\appenixsection{\parsearg\appendixsecyyy}
  1910. \outer\def\appendixsec{\parsearg\appendixsecyyy}
  1911. \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
  1912. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1913. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1914. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1915. {\chapternofonts%
  1916. \edef\temp{{\realbackslash secentry %
  1917. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1918. \escapechar=`\\%
  1919. \write \contentsfile \temp %
  1920. \appendixnoderef %
  1921. \penalty 10000 %
  1922. \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
  1923. \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
  1924. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1925. \plainsecheading {#1}\gdef\thissection{#1}%
  1926. {\chapternofonts%
  1927. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1928. \escapechar=`\\%
  1929. \write \contentsfile \temp %
  1930. \unnumbnoderef %
  1931. \penalty 10000 %
  1932. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
  1933. \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
  1934. \def\numberedsubseczzz #1{\seccheck{subsection}%
  1935. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1936. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1937. {\chapternofonts%
  1938. \edef\temp{{\realbackslash subsecentry %
  1939. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1940. \escapechar=`\\%
  1941. \write \contentsfile \temp %
  1942. \donoderef %
  1943. \penalty 10000 %
  1944. \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
  1945. \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
  1946. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1947. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1948. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1949. {\chapternofonts%
  1950. \edef\temp{{\realbackslash subsecentry %
  1951. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1952. \escapechar=`\\%
  1953. \write \contentsfile \temp %
  1954. \appendixnoderef %
  1955. \penalty 10000 %
  1956. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
  1957. \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  1958. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1959. \plainsecheading {#1}\gdef\thissection{#1}%
  1960. {\chapternofonts%
  1961. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1962. \escapechar=`\\%
  1963. \write \contentsfile \temp %
  1964. \unnumbnoderef %
  1965. \penalty 10000 %
  1966. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
  1967. \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
  1968. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  1969. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1970. \subsubsecheading {#1}
  1971.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1972. {\chapternofonts%
  1973. \edef\temp{{\realbackslash subsubsecentry %
  1974.   {#1}
  1975.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  1976.   {\noexpand\folio}}}%
  1977. \escapechar=`\\%
  1978. \write \contentsfile \temp %
  1979. \donoderef %
  1980. \penalty 10000 %
  1981. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
  1982. \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
  1983. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1984. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1985. \subsubsecheading {#1}
  1986.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1987. {\chapternofonts%
  1988. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1989.   {\appendixletter}
  1990.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  1991. \escapechar=`\\%
  1992. \write \contentsfile \temp %
  1993. \appendixnoderef %
  1994. \penalty 10000 %
  1995. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
  1996. \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  1997. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1998. \plainsecheading {#1}\gdef\thissection{#1}%
  1999. {\chapternofonts%
  2000. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  2001. \escapechar=`\\%
  2002. \write \contentsfile \temp %
  2003. \unnumbnoderef %
  2004. \penalty 10000 %
  2005. % These are variants which are not "outer", so they can appear in @ifinfo.
  2006. % Actually, they should now be obsolete; ordinary section commands should work.
  2007. \def\infotop{\parsearg\unnumberedzzz}
  2008. \def\infounnumbered{\parsearg\unnumberedzzz}
  2009. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  2010. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  2011. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  2012. \def\infoappendix{\parsearg\appendixzzz}
  2013. \def\infoappendixsec{\parsearg\appendixseczzz}
  2014. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  2015. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  2016. \def\infochapter{\parsearg\chapterzzz}
  2017. \def\infosection{\parsearg\sectionzzz}
  2018. \def\infosubsection{\parsearg\subsectionzzz}
  2019. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  2020. % These macros control what the section commands do, according
  2021. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  2022. % Define them by default for a numbered chapter.
  2023. \global\let\section = \numberedsec
  2024. \global\let\subsection = \numberedsubsec
  2025. \global\let\subsubsection = \numberedsubsubsec
  2026. % Define @majorheading, @heading and @subheading
  2027. % NOTE on use of \vbox for chapter headings, section headings, and
  2028. % such:
  2029. %    1) We use \vbox rather than the earlier \line to permit
  2030. %       overlong headings to fold.
  2031. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  2032. %       heading is obnoxious; this forbids it.
  2033. %       3) Likewise, headings look best if no \parindent is used, and
  2034. %          if justification is not attempted.  Hence \raggedright.
  2035. \def\majorheading{\parsearg\majorheadingzzz}
  2036. \def\majorheadingzzz #1{%
  2037. {\advance\chapheadingskip by 10pt \chapbreak }%
  2038. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2039.                   \parindent=0pt\raggedright
  2040.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2041. \def\chapheading{\parsearg\chapheadingzzz}
  2042. \def\chapheadingzzz #1{\chapbreak %
  2043. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2044.                   \parindent=0pt\raggedright
  2045.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2046. \def\heading{\parsearg\secheadingi}
  2047. \def\subheading{\parsearg\subsecheadingi}
  2048. \def\subsubheading{\parsearg\subsubsecheadingi}
  2049. % These macros generate a chapter, section, etc. heading only
  2050. % (including whitespace, linebreaking, etc. around it),
  2051. % given all the information in convenient, parsed form.
  2052. %%% Args are the skip and penalty (usually negative)
  2053. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  2054. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  2055. %%% Define plain chapter starts, and page on/off switching for it
  2056. % Parameter controlling skip before chapter headings (if needed)
  2057. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  2058. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  2059. \def\chappager{\par\vfill\supereject}
  2060. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  2061. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  2062. \def\CHAPPAGoff{
  2063. \global\let\pchapsepmacro=\chapbreak
  2064. \global\let\pagealignmacro=\chappager}
  2065. \def\CHAPPAGon{
  2066. \global\let\pchapsepmacro=\chappager
  2067. \global\let\pagealignmacro=\chappager
  2068. \global\def\HEADINGSon{\HEADINGSsingle}}
  2069. \def\CHAPPAGodd{
  2070. \global\let\pchapsepmacro=\chapoddpage
  2071. \global\let\pagealignmacro=\chapoddpage
  2072. \global\def\HEADINGSon{\HEADINGSdouble}}
  2073. \CHAPPAGon
  2074. \def\CHAPFplain{
  2075. \global\let\chapmacro=\chfplain
  2076. \global\let\unnumbchapmacro=\unnchfplain}
  2077. \def\chfplain #1#2{%
  2078.   \pchapsepmacro
  2079.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2080.                      \parindent=0pt\raggedright
  2081.                      \rm #2\enspace #1}%
  2082.   \bigskip
  2083.   \penalty5000
  2084. \def\unnchfplain #1{%
  2085. \pchapsepmacro %
  2086. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2087.                   \parindent=0pt\raggedright
  2088.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2089. \CHAPFplain % The default
  2090. \def\unnchfopen #1{%
  2091. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2092.                        \parindent=0pt\raggedright
  2093.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2094. \def\chfopen #1#2{\chapoddpage {\chapfonts
  2095. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  2096. \par\penalty 5000 %
  2097. \def\CHAPFopen{
  2098. \global\let\chapmacro=\chfopen
  2099. \global\let\unnumbchapmacro=\unnchfopen}
  2100. % Parameter controlling skip before section headings.
  2101. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  2102. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  2103. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  2104. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  2105. % @paragraphindent  is defined for the Info formatting commands only.
  2106. \let\paragraphindent=\comment
  2107. % Section fonts are the base font at magstep2, which produces
  2108. % a size a bit more than 14 points in the default situation.
  2109. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  2110. \def\plainsecheading #1{\secheadingi {#1}}
  2111. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  2112. \secheadingbreak}%
  2113. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2114.                  \parindent=0pt\raggedright
  2115.                  \rm #1\hfill}}%
  2116. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2117. % Subsection fonts are the base font at magstep1,
  2118. % which produces a size of 12 points.
  2119. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  2120. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2121. \subsecheadingbreak}%
  2122. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2123.                      \parindent=0pt\raggedright
  2124.                      \rm #1\hfill}}%
  2125. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2126. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  2127.                   % Perhaps make sssec fonts scaled
  2128.                   % magstep half
  2129. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  2130. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2131. \subsecheadingbreak}%
  2132. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2133.                        \parindent=0pt\raggedright
  2134.                        \rm #1\hfill}}%
  2135. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  2136. \message{toc printing,}
  2137. % Finish up the main text and prepare to read what we've written
  2138. % to \contentsfile.
  2139. \newskip\contentsrightmargin \contentsrightmargin=1in
  2140. \def\startcontents#1{%
  2141.    \pagealignmacro
  2142.    \immediate\closeout \contentsfile
  2143.    \ifnum \pageno>0
  2144.       \pageno = -1        % Request roman numbered pages.
  2145.    \fi
  2146.    % Don't need to put `Contents' or `Short Contents' in the headline.
  2147.    % It is abundantly clear what they are.
  2148.    \unnumbchapmacro{#1}\def\thischapter{}%
  2149.    \begingroup           % Set up to handle contents files properly.
  2150.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  2151.       \raggedbottom             % Worry more about breakpoints than the bottom.
  2152.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  2153. % Normal (long) toc.
  2154. \outer\def\contents{%
  2155.    \startcontents{\putwordTableofContents}%
  2156.       \input \jobname.toc
  2157.    \endgroup
  2158.    \vfill \eject
  2159. % And just the chapters.
  2160. \outer\def\summarycontents{%
  2161.    \startcontents{\putwordShortContents}%
  2162.       %
  2163.       \let\chapentry = \shortchapentry
  2164.       \let\unnumbchapentry = \shortunnumberedentry
  2165.       % We want a true roman here for the page numbers.
  2166.       \secfonts
  2167.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  2168.       \rm
  2169.       \advance\baselineskip by 1pt % Open it up a little.
  2170.       \def\secentry ##1##2##3##4{}
  2171.       \def\unnumbsecentry ##1##2{}
  2172.       \def\subsecentry ##1##2##3##4##5{}
  2173.       \def\unnumbsubsecentry ##1##2{}
  2174.       \def\subsubsecentry ##1##2##3##4##5##6{}
  2175.       \def\unnumbsubsubsecentry ##1##2{}
  2176.       \input \jobname.toc
  2177.    \endgroup
  2178.    \vfill \eject
  2179. \let\shortcontents = \summarycontents
  2180. % These macros generate individual entries in the table of contents.
  2181. % The first argument is the chapter or section name.
  2182. % The last argument is the page number.
  2183. % The arguments in between are the chapter number, section number, ...
  2184. % Chapter-level things, for both the long and short contents.
  2185. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  2186. % See comments in \dochapentry re vbox and related settings
  2187. \def\shortchapentry#1#2#3{%
  2188.   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  2189. % Typeset the label for a chapter or appendix for the short contents.
  2190. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  2191. % We could simplify the code here by writing out an \appendixentry
  2192. % command in the toc file for appendices, instead of using \chapentry
  2193. % for both, but it doesn't seem worth it.
  2194. \setbox0 = \hbox{\shortcontrm \putwordAppendix }
  2195. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  2196. \def\shortchaplabel#1{%
  2197.   % We typeset #1 in a box of constant width, regardless of the text of
  2198.   % #1, so the chapter titles will come out aligned.
  2199.   \setbox0 = \hbox{#1}%
  2200.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  2201.   % This space should be plenty, since a single number is .5em, and the
  2202.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  2203.   % (This space doesn't include the extra space that gets added after
  2204.   % the label; that gets put in in \shortchapentry above.)
  2205.   \advance\dimen0 by 1.1em
  2206.   \hbox to \dimen0{#1\hfil}%
  2207. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  2208. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  2209. % Sections.
  2210. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  2211. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  2212. % Subsections.
  2213. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  2214. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  2215. % And subsubsections.
  2216. \def\subsubsecentry#1#2#3#4#5#6{%
  2217.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  2218. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  2219. % This parameter controls the indentation of the various levels.
  2220. \newdimen\tocindent \tocindent = 3pc
  2221. % Now for the actual typesetting. In all these, #1 is the text and #2 is the
  2222. % page number.
  2223. % If the toc has to be broken over pages, we would want to be at chapters
  2224. % if at all possible; hence the \penalty.
  2225. \def\dochapentry#1#2{%
  2226.    \penalty-300 \vskip\baselineskip
  2227.    \begingroup
  2228.      \chapentryfonts
  2229.      \tocentry{#1}{\dopageno{#2}}%
  2230.    \endgroup
  2231.    \nobreak\vskip .25\baselineskip
  2232. \def\dosecentry#1#2{\begingroup
  2233.   \secentryfonts \leftskip=\tocindent
  2234.   \tocentry{#1}{\dopageno{#2}}%
  2235. \endgroup}
  2236. \def\dosubsecentry#1#2{\begingroup
  2237.   \subsecentryfonts \leftskip=2\tocindent
  2238.   \tocentry{#1}{\dopageno{#2}}%
  2239. \endgroup}
  2240. \def\dosubsubsecentry#1#2{\begingroup
  2241.   \subsubsecentryfonts \leftskip=3\tocindent
  2242.   \tocentry{#1}{\dopageno{#2}}%
  2243. \endgroup}
  2244. % Final typesetting of a toc entry; we use the same \entry macro as for
  2245. % the index entries, but we want to suppress hyphenation here.  (We
  2246. % can't do that in the \entry macro, since index entries might consist
  2247. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  2248. \def\tocentry#1#2{\begingroup
  2249.   \hyphenpenalty = 10000
  2250.   \entry{#1}{#2}%
  2251. \endgroup}
  2252. % Space between chapter (or whatever) number and the title.
  2253. \def\labelspace{\hskip1em \relax}
  2254. \def\dopageno#1{{\rm #1}}
  2255. \def\doshortpageno#1{{\rm #1}}
  2256. \def\chapentryfonts{\secfonts \rm}
  2257. \def\secentryfonts{\textfonts}
  2258. \let\subsecentryfonts = \textfonts
  2259. \let\subsubsecentryfonts = \textfonts
  2260. \message{environments,}
  2261. % Since these characters are used in examples, it should be an even number of
  2262. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  2263. % Furthermore, these definitions must come after we define our fonts.
  2264. \newbox\dblarrowbox    \newbox\longdblarrowbox
  2265. \newbox\pushcharbox    \newbox\bullbox
  2266. \newbox\equivbox       \newbox\errorbox
  2267. \let\ptexequiv = \equiv
  2268. %{\tentt
  2269. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  2270. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  2271. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  2272. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2273. % Adapted from the manmac format (p.420 of TeXbook)
  2274. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2275. %                                      depth .1ex\hfil}
  2276. \def\point{$\star$}
  2277. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  2278. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  2279. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  2280. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  2281. % Adapted from the TeXbook's \boxit.
  2282. {\tentt \global\dimen0 = 3em}% Width of the box.
  2283. \dimen2 = .55pt % Thickness of rules
  2284. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  2285. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  2286. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  2287.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  2288.    \advance\hsize by -2\dimen2 % Rules.
  2289.    \vbox{
  2290.       \hrule height\dimen2
  2291.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  2292.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  2293.          \kern3pt\vrule width\dimen2}% Space to right.
  2294.       \hrule height\dimen2}
  2295.     \hfil}
  2296. % The @error{} command.
  2297. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  2298. % @tex ... @end tex    escapes into raw Tex temporarily.
  2299. % One exception: @ is still an escape character, so that @end tex works.
  2300. % But \@ or @@ will get a plain tex @ character.
  2301. \def\tex{\begingroup
  2302. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  2303. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  2304. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  2305. \catcode `\%=14
  2306. \catcode 43=12
  2307. \catcode`\"=12
  2308. \catcode`\==12
  2309. \catcode`\|=12
  2310. \catcode`\<=12
  2311. \catcode`\>=12
  2312. \escapechar=`\\
  2313. \let\{=\ptexlbrace
  2314. \let\}=\ptexrbrace
  2315. \let\.=\ptexdot
  2316. \let\*=\ptexstar
  2317. \let\dots=\ptexdots
  2318. \def\@{@}%
  2319. \let\bullet=\ptexbullet
  2320. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  2321. \let\L=\ptexL
  2322. \let\Etex=\endgroup}
  2323. % Define @lisp ... @endlisp.
  2324. % @lisp does a \begingroup so it can rebind things,
  2325. % including the definition of @endlisp (which normally is erroneous).
  2326. % Amount to narrow the margins by for @lisp.
  2327. \newskip\lispnarrowing \lispnarrowing=0.4in
  2328. % This is the definition that ^^M gets inside @lisp, @example, and other
  2329. % such environments.  \null is better than a space, since it doesn't
  2330. % have any width.
  2331. \def\lisppar{\null\endgraf}
  2332. % Make each space character in the input produce a normal interword
  2333. % space in the output.  Don't allow a line break at this space, as this
  2334. % is used only in environments like @example, where each line of input
  2335. % should produce a line of output anyway.
  2336. {\obeyspaces %
  2337. \gdef\sepspaces{\obeyspaces\let =\tie}}
  2338. % Define \obeyedspace to be our active space, whatever it is.  This is
  2339. % for use in \parsearg.
  2340. {\sepspaces%
  2341. \global\let\obeyedspace= }
  2342. % This space is always present above and below environments.
  2343. \newskip\envskipamount \envskipamount = 0pt
  2344. % Make spacing and below environment symmetrical.  We use \parskip here
  2345. % to help in doing that, since in @example-like environments \parskip
  2346. % is reset to zero; thus the \afterenvbreak inserts no space -- but the
  2347. % start of the next paragraph will insert \parskip
  2348. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  2349. \endgraf \ifdim\lastskip<\envskipamount
  2350. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  2351. \let\afterenvbreak = \aboveenvbreak
  2352. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  2353. \let\nonarrowing=\relax
  2354. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2355. % \cartouche: draw rectangle w/rounded corners around argument
  2356. \font\circle=lcircle10
  2357. \newdimen\circthick
  2358. \newdimen\cartouter\newdimen\cartinner
  2359. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  2360. \circthick=\fontdimen8\circle
  2361. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  2362. \def\ctr{{\hskip 6pt\circle\char'010}}
  2363. \def\cbl{{\circle\char'012\hskip -6pt}}
  2364. \def\cbr{{\hskip 6pt\circle\char'011}}
  2365. \def\carttop{\hbox to \cartouter{\hskip\lskip
  2366.     \ctl\leaders\hrule height\circthick\hfil\ctr
  2367.     \hskip\rskip}}
  2368. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  2369.     \cbl\leaders\hrule height\circthick\hfil\cbr
  2370.     \hskip\rskip}}
  2371. \newskip\lskip\newskip\rskip
  2372. \long\def\cartouche{%
  2373. \begingroup
  2374.     \lskip=\leftskip \rskip=\rightskip
  2375.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  2376.     \cartinner=\hsize \advance\cartinner by-\lskip
  2377.                \advance\cartinner by-\rskip
  2378.     \cartouter=\hsize
  2379.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  2380. %                     side, and for 6pt waste from
  2381. %                     each corner char
  2382.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  2383.     % Flag to tell @lisp, etc., not to narrow margin.
  2384.     \let\nonarrowing=\comment
  2385.     \vbox\bgroup
  2386.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  2387.         \carttop
  2388.         \hbox\bgroup
  2389.             \hskip\lskip
  2390.             \vrule\kern3pt
  2391.             \vbox\bgroup
  2392.                 \hsize=\cartinner
  2393.                 \kern3pt
  2394.                 \begingroup
  2395.                     \baselineskip=\normbskip
  2396.                     \lineskip=\normlskip
  2397.                     \parskip=\normpskip
  2398.                     \vskip -\parskip
  2399. \def\Ecartouche{%
  2400.                 \endgroup
  2401.                 \kern3pt
  2402.             \egroup
  2403.             \kern3pt\vrule
  2404.             \hskip\rskip
  2405.         \egroup
  2406.         \cartbot
  2407.     \egroup
  2408. \endgroup
  2409. % This macro is called at the beginning of all the @example variants,
  2410. % inside a group.
  2411. \def\nonfillstart{%
  2412.   \aboveenvbreak
  2413.   \inENV % This group ends at the end of the body
  2414.   \hfuzz = 12pt % Don't be fussy
  2415.   \sepspaces % Make spaces be word-separators rather than space tokens.
  2416.   \singlespace
  2417.   \let\par = \lisppar % don't ignore blank lines
  2418.   \obeylines % each line of input is a line of output
  2419.   \parskip = 0pt
  2420.   \parindent = 0pt
  2421.   \emergencystretch = 0pt % don't try to avoid overfull boxes
  2422.   % @cartouche defines \nonarrowing to inhibit narrowing
  2423.   % at next level down.
  2424.   \ifx\nonarrowing\relax
  2425.     \advance \leftskip by \lispnarrowing
  2426.     \exdentamount=\lispnarrowing
  2427.     \let\exdent=\nofillexdent
  2428.     \let\nonarrowing=\relax
  2429.   \fi
  2430. % To ending an @example-like environment, we first end the paragraph
  2431. % (via \afterenvbreak's vertical glue), and then the group.  That way we
  2432. % keep the zero \parskip that the environments set -- \parskip glue
  2433. % will be inserted at the beginning of the next paragraph in the
  2434. % document, after the environment.
  2435. \def\nonfillfinish{\afterenvbreak\endgroup}%
  2436. % This macro is
  2437. \def\lisp{\begingroup
  2438.   \nonfillstart
  2439.   \let\Elisp = \nonfillfinish
  2440.   \tt
  2441.   \rawbackslash % have \ input char produce \ char from current font
  2442.   \gobble
  2443. % Define the \E... control sequence only if we are inside the
  2444. % environment, so the error checking in \end will work.
  2445. % We must call \lisp last in the definition, since it reads the
  2446. % return following the @example (or whatever) command.
  2447. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
  2448. \def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp}
  2449. \def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
  2450. % @smallexample and @smalllisp.  This is not used unless the @smallbook
  2451. % command is given.  Originally contributed by Pavel@xerox.
  2452. \def\smalllispx{\begingroup
  2453.   \nonfillstart
  2454.   \let\Esmalllisp = \nonfillfinish
  2455.   \let\Esmallexample = \nonfillfinish
  2456.   % Smaller interline space and fonts for small examples.
  2457.   \setleading{10pt}%
  2458.   \indexfonts \tt
  2459.   \rawbackslash % make \ output the \ character from the current font (tt)
  2460.   \gobble
  2461. % This is @display; same as @lisp except use roman font.
  2462. \def\display{\begingroup
  2463.   \nonfillstart
  2464.   \let\Edisplay = \nonfillfinish
  2465.   \gobble
  2466. % This is @format; same as @display except don't narrow margins.
  2467. \def\format{\begingroup
  2468.   \let\nonarrowing = t
  2469.   \nonfillstart
  2470.   \let\Eformat = \nonfillfinish
  2471.   \gobble
  2472. % @flushleft (same as @format) and @flushright.
  2473. \def\flushleft{\begingroup
  2474.   \let\nonarrowing = t
  2475.   \nonfillstart
  2476.   \let\Eflushleft = \nonfillfinish
  2477.   \gobble
  2478. \def\flushright{\begingroup
  2479.   \let\nonarrowing = t
  2480.   \nonfillstart
  2481.   \let\Eflushright = \nonfillfinish
  2482.   \advance\leftskip by 0pt plus 1fill
  2483.   \gobble}
  2484. % @quotation does normal linebreaking and narrows the margins.
  2485. \def\quotation{%
  2486. \begingroup\inENV %This group ends at the end of the @quotation body
  2487. {\parskip=0pt  % because we will skip by \parskip too, later
  2488. \aboveenvbreak}%
  2489. \singlespace
  2490. \parindent=0pt
  2491. \let\Equotation = \nonfillfinish
  2492. % @cartouche defines \nonarrowing to inhibit narrowing
  2493. % at next level down.
  2494. \ifx\nonarrowing\relax
  2495. \advance \leftskip by \lispnarrowing
  2496. \advance \rightskip by \lispnarrowing
  2497. \exdentamount=\lispnarrowing
  2498. \let\nonarrowing=\relax
  2499. \message{defuns,}
  2500. % Define formatter for defuns
  2501. % First, allow user to change definition object font (\df) internally
  2502. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2503. \newskip\defbodyindent \defbodyindent=.4in
  2504. \newskip\defargsindent \defargsindent=50pt
  2505. \newskip\deftypemargin \deftypemargin=12pt
  2506. \newskip\deflastargmargin \deflastargmargin=18pt
  2507. \newcount\parencount
  2508. % define \functionparens, which makes ( and ) and & do special things.
  2509. % \functionparens affects the group it is contained in.
  2510. \def\activeparens{%
  2511. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2512. \catcode`\[=\active \catcode`\]=\active}
  2513. % Make control sequences which act like normal parenthesis chars.
  2514. \let\lparen = ( \let\rparen = )
  2515. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2516. % Be sure that we always have a definition for `(', etc.  For example,
  2517. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2518. % so TeX would otherwise complain about undefined control sequence.
  2519. \global\let(=\lparen \global\let)=\rparen
  2520. \global\let[=\lbrack \global\let]=\rbrack
  2521. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2522. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2523. % Definitions of (, ) and & used in args for functions.
  2524. % This is the definition of ( outside of all parentheses.
  2525. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2526. \global\advance\parencount by 1 }
  2527. % This is the definition of ( when already inside a level of parens.
  2528. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2529. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2530. % also in that case restore the outer-level definition of (.
  2531. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2532. \global\advance \parencount by -1 }
  2533. % If we encounter &foo, then turn on ()-hacking afterwards
  2534. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2535. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2536. } % End of definition inside \activeparens
  2537. %% These parens (in \boldbrax) actually are a little bolder than the
  2538. %% contained text.  This is especially needed for [ and ]
  2539. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2540. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2541. % First, defname, which formats the header line itself.
  2542. % #1 should be the function name.
  2543. % #2 should be the type of definition, such as "Function".
  2544. \def\defname #1#2{%
  2545. % Get the values of \leftskip and \rightskip as they were
  2546. % outside the @def...
  2547. \dimen2=\leftskip
  2548. \advance\dimen2 by -\defbodyindent
  2549. \dimen3=\rightskip
  2550. \advance\dimen3 by -\defbodyindent
  2551. \noindent        %
  2552. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2553. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2554. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2555. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2556. % Now output arg 2 ("Function" or some such)
  2557. % ending at \deftypemargin from the right margin,
  2558. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2559. {% Adjust \hsize to exclude the ambient margins,
  2560. % so that \rightline will obey them.
  2561. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2562. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2563. % Make all lines underfull and no complaints:
  2564. \tolerance=10000 \hbadness=10000
  2565. \advance\leftskip by -\defbodyindent
  2566. \exdentamount=\defbodyindent
  2567. {\df #1}\enskip        % Generate function name
  2568. % Actually process the body of a definition
  2569. % #1 should be the terminating control sequence, such as \Edefun.
  2570. % #2 should be the "another name" control sequence, such as \defunx.
  2571. % #3 should be the control sequence that actually processes the header,
  2572. %    such as \defunheader.
  2573. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2574. \medbreak %
  2575. % Define the end token that this defining construct specifies
  2576. % so that it will exit this group.
  2577. \def#1{\endgraf\endgroup\medbreak}%
  2578. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2579. \parindent=0in
  2580. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2581. \exdentamount=\defbodyindent
  2582. \begingroup %
  2583. \catcode 61=\active % 61 is `='
  2584. \obeylines\activeparens\spacesplit#3}
  2585. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2586. \medbreak %
  2587. % Define the end token that this defining construct specifies
  2588. % so that it will exit this group.
  2589. \def#1{\endgraf\endgroup\medbreak}%
  2590. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2591. \parindent=0in
  2592. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2593. \exdentamount=\defbodyindent
  2594. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2595. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2596. \medbreak %
  2597. % Define the end token that this defining construct specifies
  2598. % so that it will exit this group.
  2599. \def#1{\endgraf\endgroup\medbreak}%
  2600. \def#2##1 ##2 {\def#4{##1}%
  2601. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2602. \parindent=0in
  2603. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2604. \exdentamount=\defbodyindent
  2605. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2606. % These parsing functions are similar to the preceding ones
  2607. % except that they do not make parens into active characters.
  2608. % These are used for "variables" since they have no arguments.
  2609. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2610. \medbreak %
  2611. % Define the end token that this defining construct specifies
  2612. % so that it will exit this group.
  2613. \def#1{\endgraf\endgroup\medbreak}%
  2614. \def#2{\begingroup\obeylines\spacesplit#3}%
  2615. \parindent=0in
  2616. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2617. \exdentamount=\defbodyindent
  2618. \begingroup %
  2619. \catcode 61=\active %
  2620. \obeylines\spacesplit#3}
  2621. % This is used for \def{tp,vr}parsebody.  It could probably be used for
  2622. % some of the others, too, with some judicious conditionals.
  2623. \def\parsebodycommon#1#2#3{%
  2624.   \begingroup\inENV %
  2625.   \medbreak %
  2626.   % Define the end token that this defining construct specifies
  2627.   % so that it will exit this group.
  2628.   \def#1{\endgraf\endgroup\medbreak}%
  2629.   \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2630.   \parindent=0in
  2631.   \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2632.   \exdentamount=\defbodyindent
  2633.   \begingroup\obeylines
  2634. \def\defvrparsebody#1#2#3#4 {%
  2635.   \parsebodycommon{#1}{#2}{#3}%
  2636.   \spacesplit{#3{#4}}%
  2637. % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
  2638. % type is just `struct', because we lose the braces in `{struct
  2639. % termios}' when \spacesplit reads its undelimited argument.  Sigh.
  2640. % \let\deftpparsebody=\defvrparsebody
  2641. % So, to get around this, we put \empty in with the type name.  That
  2642. % way, TeX won't find exactly `{...}' as an undelimited argument, and
  2643. % won't strip off the braces.
  2644. \def\deftpparsebody #1#2#3#4 {%
  2645.   \parsebodycommon{#1}{#2}{#3}%
  2646.   \spacesplit{\parsetpheaderline{#3{#4}}}\empty
  2647. % Fine, but then we have to eventually remove the \empty *and* the
  2648. % braces (if any).  That's what this does, putting the result in \tptemp.
  2649. \def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}%
  2650. % After \spacesplit has done its work, this is called -- #1 is the final
  2651. % thing to call, #2 the type name (which starts with \empty), and #3
  2652. % (which might be empty) the arguments.
  2653. \def\parsetpheaderline#1#2#3{%
  2654.   \removeemptybraces#2\relax
  2655.   #1{\tptemp}{#3}%
  2656. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  2657. \medbreak %
  2658. % Define the end token that this defining construct specifies
  2659. % so that it will exit this group.
  2660. \def#1{\endgraf\endgroup\medbreak}%
  2661. \def#2##1 ##2 {\def#4{##1}%
  2662. \begingroup\obeylines\spacesplit{#3{##2}}}%
  2663. \parindent=0in
  2664. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2665. \exdentamount=\defbodyindent
  2666. \begingroup\obeylines\spacesplit{#3{#5}}}
  2667. % Split up #2 at the first space token.
  2668. % call #1 with two arguments:
  2669. %  the first is all of #2 before the space token,
  2670. %  the second is all of #2 after that space token.
  2671. % If #2 contains no space token, all of it is passed as the first arg
  2672. % and the second is passed as empty.
  2673. {\obeylines
  2674. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2675. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2676. \ifx\relax #3%
  2677. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2678. % So much for the things common to all kinds of definitions.
  2679. % Define @defun.
  2680. % First, define the processing that is wanted for arguments of \defun
  2681. % Use this to expand the args and terminate the paragraph they make up
  2682. \def\defunargs #1{\functionparens \sl
  2683. % Expand, preventing hyphenation at `-' chars.
  2684. % Note that groups don't affect changes in \hyphenchar.
  2685. \hyphenchar\tensl=0
  2686. \hyphenchar\tensl=45
  2687. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2688. \interlinepenalty=10000
  2689. \advance\rightskip by 0pt plus 1fil
  2690. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2691. \def\deftypefunargs #1{%
  2692. % Expand, preventing hyphenation at `-' chars.
  2693. % Note that groups don't affect changes in \hyphenchar.
  2694. \functionparens
  2695. \tclose{#1}% avoid \code because of side effects on active chars
  2696. \interlinepenalty=10000
  2697. \advance\rightskip by 0pt plus 1fil
  2698. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2699. % Do complete processing of one @defun or @defunx line already parsed.
  2700. % @deffn Command forward-char nchars
  2701. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2702. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2703. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2704. \catcode 61=\other % Turn off change made in \defparsebody
  2705. % @defun == @deffn Function
  2706. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2707. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2708. \begingroup\defname {#1}{Function}%
  2709. \defunargs {#2}\endgroup %
  2710. \catcode 61=\other % Turn off change made in \defparsebody
  2711. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2712. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2713. % #1 is the data type.  #2 is the name and args.
  2714. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2715. % #1 is the data type, #2 the name, #3 the args.
  2716. \def\deftypefunheaderx #1#2 #3\relax{%
  2717. \doind {fn}{\code{#2}}% Make entry in function index
  2718. \begingroup\defname {\code{#1} #2}{Function}%
  2719. \deftypefunargs {#3}\endgroup %
  2720. \catcode 61=\other % Turn off change made in \defparsebody
  2721. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2722. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2723. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2724. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2725. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2726. \def\deftypefnheaderx #1#2#3 #4\relax{%
  2727. \doind {fn}{\code{#3}}% Make entry in function index
  2728. \begingroup
  2729. \normalparens % notably, turn off `&' magic, which prevents
  2730. %               at least some C++ text from working
  2731. \defname {\code{#2} #3}{#1}%
  2732. \deftypefunargs {#4}\endgroup %
  2733. \catcode 61=\other % Turn off change made in \defparsebody
  2734. % @defmac == @deffn Macro
  2735. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2736. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2737. \begingroup\defname {#1}{Macro}%
  2738. \defunargs {#2}\endgroup %
  2739. \catcode 61=\other % Turn off change made in \defparsebody
  2740. % @defspec == @deffn Special Form
  2741. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2742. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2743. \begingroup\defname {#1}{Special Form}%
  2744. \defunargs {#2}\endgroup %
  2745. \catcode 61=\other % Turn off change made in \defparsebody
  2746. % This definition is run if you use @defunx
  2747. % anywhere other than immediately after a @defun or @defunx.
  2748. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2749. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2750. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2751. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2752. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2753. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2754. % @defmethod, and so on
  2755. % @defop {Funny Method} foo-class frobnicate argument
  2756. \def\defop #1 {\def\defoptype{#1}%
  2757. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2758. \def\defopheader #1#2#3{%
  2759. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2760. \begingroup\defname {#2}{\defoptype{} on #1}%
  2761. \defunargs {#3}\endgroup %
  2762. % @defmethod == @defop Method
  2763. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2764. \def\defmethodheader #1#2#3{%
  2765. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2766. \begingroup\defname {#2}{Method on #1}%
  2767. \defunargs {#3}\endgroup %
  2768. % @defcv {Class Option} foo-class foo-flag
  2769. \def\defcv #1 {\def\defcvtype{#1}%
  2770. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2771. \def\defcvarheader #1#2#3{%
  2772. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2773. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2774. \defvarargs {#3}\endgroup %
  2775. % @defivar == @defcv {Instance Variable}
  2776. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  2777. \def\defivarheader #1#2#3{%
  2778. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2779. \begingroup\defname {#2}{Instance Variable of #1}%
  2780. \defvarargs {#3}\endgroup %
  2781. % These definitions are run if you use @defmethodx, etc.,
  2782. % anywhere other than immediately after a @defmethod, etc.
  2783. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2784. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2785. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2786. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2787. % Now @defvar
  2788. % First, define the processing that is wanted for arguments of @defvar.
  2789. % This is actually simple: just print them in roman.
  2790. % This must expand the args and terminate the paragraph they make up
  2791. \def\defvarargs #1{\normalparens #1%
  2792. \interlinepenalty=10000
  2793. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2794. % @defvr Counter foo-count
  2795. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  2796. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2797. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2798. % @defvar == @defvr Variable
  2799. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  2800. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2801. \begingroup\defname {#1}{Variable}%
  2802. \defvarargs {#2}\endgroup %
  2803. % @defopt == @defvr {User Option}
  2804. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  2805. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2806. \begingroup\defname {#1}{User Option}%
  2807. \defvarargs {#2}\endgroup %
  2808. % @deftypevar int foobar
  2809. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2810. % #1 is the data type.  #2 is the name.
  2811. \def\deftypevarheader #1#2{%
  2812. \doind {vr}{\code{#2}}% Make entry in variables index
  2813. \begingroup\defname {\code{#1} #2}{Variable}%
  2814. \interlinepenalty=10000
  2815. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2816. \endgroup}
  2817. % @deftypevr {Global Flag} int enable
  2818. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2819. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2820. \begingroup\defname {\code{#2} #3}{#1}
  2821. \interlinepenalty=10000
  2822. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2823. \endgroup}
  2824. % This definition is run if you use @defvarx
  2825. % anywhere other than immediately after a @defvar or @defvarx.
  2826. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2827. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2828. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2829. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2830. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2831. % Now define @deftp
  2832. % Args are printed in bold, a slight difference from @defvar.
  2833. \def\deftpargs #1{\bf \defvarargs{#1}}
  2834. % @deftp Class window height width ...
  2835. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  2836. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2837. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2838. % This definition is run if you use @deftpx, etc
  2839. % anywhere other than immediately after a @deftp, etc.
  2840. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2841. \message{cross reference,}
  2842. % Define cross-reference macros
  2843. \newwrite \auxfile
  2844. \newif\ifhavexrefs  % True if xref values are known.
  2845. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2846. % \setref{foo} defines a cross-reference point named foo.
  2847. \def\setref#1{%
  2848. \dosetq{#1-title}{Ytitle}%
  2849. \dosetq{#1-pg}{Ypagenumber}%
  2850. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2851. \def\unnumbsetref#1{%
  2852. \dosetq{#1-title}{Ytitle}%
  2853. \dosetq{#1-pg}{Ypagenumber}%
  2854. \dosetq{#1-snt}{Ynothing}}
  2855. \def\appendixsetref#1{%
  2856. \dosetq{#1-title}{Ytitle}%
  2857. \dosetq{#1-pg}{Ypagenumber}%
  2858. \dosetq{#1-snt}{Yappendixletterandtype}}
  2859. % \xref, \pxref, and \ref generate cross-references to specified points.
  2860. % For \xrefX, #1 is the node name, #2 the name of the Info
  2861. % cross-reference, #3 the printed node name, #4 the name of the Info
  2862. % file, #5 the name of the printed manual.  All but the node name can be
  2863. % omitted.
  2864. \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
  2865. \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
  2866. \def\ref#1{\xrefX[#1,,,,,,,]}
  2867. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  2868. \def\printedmanual{\ignorespaces #5}%
  2869. \def\printednodename{\ignorespaces #3}%
  2870. \def\correctnodename{{\normalturnoffactive\printednodename}}%
  2871. \setbox1=\hbox{\printedmanual}%
  2872. \setbox0=\hbox{\printednodename}%
  2873. \ifdim \wd0=0pt%
  2874. % No printed node name was explicitly given.
  2875. \ifx SETxref-automatic-section-title %
  2876. % This line should make the actual chapter or section title appear inside
  2877. % the square brackets.  Use the real section title if we have it.
  2878. \ifdim \wd1>0pt%
  2879. % It is in another manual, so we don't have it.
  2880. \def\printednodename{\ignorespaces #1} \else%
  2881. % We know the real title if we have the xref values.
  2882. \ifhavexrefs \def\printednodename{\refx{#1-title}}%
  2883. % Otherwise just copy the Info node name.
  2884. \else \def\printednodename{\ignorespaces #1} \fi%
  2885. \fi\def\printednodename{#1-title}%
  2886. \else% This line just uses the node name.
  2887. \def\printednodename{\ignorespaces #1}%
  2888. \fi% ends \ifx SETxref-automatic-section-title
  2889. \fi% ends \ifdim \wd0
  2890. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  2891. % not insert empty discretionaries after hyphens, which means that it
  2892. % will not find a line break at a hyphen in a node names.  Since some
  2893. % manuals are best written with fairly long node names, containing
  2894. % hyphens, this is a loss.  Therefore, we simply give the text of
  2895. % the node name again, so it is as if TeX is seeing it for the first
  2896. % time.
  2897. \ifdim \wd1>0pt
  2898. \putwordsection{} ``\correctnodename'' in \cite{\printedmanual}%
  2899. \else%
  2900. \turnoffactive%
  2901. \refx{#1-snt}{} [\correctnodename], \putwordpage\tie\refx{#1-pg}{}%
  2902. \endgroup}
  2903. % \dosetq is the interface for calls from other macros
  2904. % Use \turnoffactive so that punctuation chars such as underscore
  2905. % work in node names.
  2906. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2907. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2908. \next}}
  2909. % \internalsetq {foo}{page} expands into
  2910. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2911. % When the aux file is read, ' is the escape character
  2912. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2913. % Things to be expanded by \internalsetq
  2914. \def\Ypagenumber{\folio}
  2915. \def\Ytitle{\thissection}
  2916. \def\Ynothing{}
  2917. \def\Ysectionnumberandtype{%
  2918. \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
  2919. \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
  2920. \else \ifnum \subsubsecno=0 %
  2921. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
  2922. \else %
  2923. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2924. \fi \fi \fi }
  2925. \def\Yappendixletterandtype{%
  2926. \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
  2927. \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
  2928. \else \ifnum \subsubsecno=0 %
  2929. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2930. \else %
  2931. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2932. \fi \fi \fi }
  2933. \gdef\xreftie{'tie}
  2934. % Use TeX 3.0's \inputlineno to get the line number, for better error
  2935. % messages, but if we're using an old version of TeX, don't do anything.
  2936. \ifx\inputlineno\thisisundefined
  2937.   \let\linenumber = \empty % Non-3.0.
  2938. \else
  2939.   \def\linenumber{\the\inputlineno:\space}
  2940. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2941. % If its value is nonempty, SUFFIX is output afterward.
  2942. \def\refx#1#2{%
  2943.   \expandafter\ifx\csname X#1\endcsname\relax
  2944.     % If not defined, say something at least.
  2945.     $\langle$un\-de\-fined$\rangle$%
  2946.     \ifhavexrefs
  2947.       \message{\linenumber Undefined cross reference `#1'.}%
  2948.     \else
  2949.       \ifwarnedxrefs\else
  2950.         \global\warnedxrefstrue
  2951.         \message{Cross reference values unknown; you must run TeX again.}%
  2952.       \fi
  2953.     \fi
  2954.   \else
  2955.     % It's defined, so just use it.
  2956.     \csname X#1\endcsname
  2957.   \fi
  2958.   #2% Output the suffix in any case.
  2959. % Read the last existing aux file, if any.  No error if none exists.
  2960. % This is the macro invoked by entries in the aux file.
  2961. \def\xrdef #1#2{
  2962. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2963. \def\readauxfile{%
  2964. \begingroup
  2965. \catcode `\^^@=\other
  2966. \catcode `\
  2967. =\other
  2968. \catcode `\
  2969. =\other
  2970. \catcode `\^^C=\other
  2971. \catcode `\^^D=\other
  2972. \catcode `\^^E=\other
  2973. \catcode `\^^F=\other
  2974. \catcode `\^^G=\other
  2975. \catcode `\^^H=\other
  2976. \catcode `\
  2977. =\other
  2978. \catcode `\^^L=\other
  2979. \catcode `\
  2980. =\other
  2981. \catcode `\
  2982. =\other
  2983. \catcode `\
  2984. =\other
  2985. \catcode `\
  2986. =\other
  2987. \catcode `\
  2988. =\other
  2989. \catcode `\
  2990. =\other
  2991. \catcode `\
  2992. =\other
  2993. \catcode `\
  2994. =\other
  2995. \catcode `\
  2996. =\other
  2997. \catcode `\
  2998. =\other
  2999. \catcode `\
  3000. =\other
  3001. \catcode `\
  3002. =\other
  3003. \catcode 26=\other
  3004. \catcode `\^^[=\other
  3005. \catcode `\^^\=\other
  3006. \catcode `\^^]=\other
  3007. \catcode `\^^^=\other
  3008. \catcode `\^^_=\other
  3009. \catcode `\@=\other
  3010. \catcode `\^=\other
  3011. \catcode `\~=\other
  3012. \catcode `\[=\other
  3013. \catcode `\]=\other
  3014. \catcode`\"=\other
  3015. \catcode`\_=\other
  3016. \catcode`\|=\other
  3017. \catcode`\<=\other
  3018. \catcode`\>=\other
  3019. \catcode `\$=\other
  3020. \catcode `\#=\other
  3021. \catcode `\&=\other
  3022. % `\+ does not work, so use 43.
  3023. \catcode 43=\other
  3024. % the aux file uses ' as the escape.
  3025. % Turn off \ as an escape so we do not lose on
  3026. % entries which were dumped with control sequences in their names.
  3027. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  3028. % Reference to such entries still does not work the way one would wish,
  3029. % but at least they do not bomb out when the aux file is read in.
  3030. \catcode `\{=1 \catcode `\}=2
  3031. \catcode `\%=\other
  3032. \catcode `\'=0
  3033. \catcode `\\=\other
  3034. \openin 1 \jobname.aux
  3035. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  3036. \global\warnedobstrue
  3037. % Open the new aux file.  Tex will close it automatically at exit.
  3038. \openout \auxfile=\jobname.aux
  3039. \endgroup}
  3040. % Footnotes.
  3041. \newcount \footnoteno
  3042. % The trailing space in the following definition for supereject is
  3043. % vital for proper filling; pages come out unaligned when you do a
  3044. % pagealignmacro call if that space before the closing brace is
  3045. % removed.
  3046. \def\supereject{\par\penalty -20000\footnoteno =0 }
  3047. % @footnotestyle is meaningful for info output only..
  3048. \let\footnotestyle=\comment
  3049. \let\ptexfootnote=\footnote
  3050. {\catcode `\@=11
  3051. % Auto-number footnotes.  Otherwise like plain.
  3052. \gdef\footnote{%
  3053.   \global\advance\footnoteno by \@ne
  3054.   \edef\thisfootno{$^{\the\footnoteno}$}%
  3055.   % In case the footnote comes at the end of a sentence, preserve the
  3056.   % extra spacing after we do the footnote number.
  3057.   \let\@sf\empty
  3058.   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  3059.   % Remove inadvertent blank space before typesetting the footnote number.
  3060.   \unskip
  3061.   \thisfootno\@sf
  3062.   \footnotezzz
  3063. % Don't bother with the trickery in plain.tex to not require the
  3064. % footnote text as a parameter.  Our footnotes don't need to be so general.
  3065. \long\gdef\footnotezzz#1{\insert\footins{%
  3066.   % We want to typeset this text as a normal paragraph, even if the
  3067.   % footnote reference occurs in (for example) a display environment.
  3068.   % So reset some parameters.
  3069.   \interlinepenalty\interfootnotelinepenalty
  3070.   \splittopskip\ht\strutbox % top baseline for broken footnotes
  3071.   \splitmaxdepth\dp\strutbox
  3072.   \floatingpenalty\@MM
  3073.   \leftskip\z@skip
  3074.   \rightskip\z@skip
  3075.   \spaceskip\z@skip
  3076.   \xspaceskip\z@skip
  3077.   \parindent\defaultparindent
  3078.   % Hang the footnote text off the number.
  3079.   \hang
  3080.   \textindent{\thisfootno}%
  3081.   % Don't crash into the line above the footnote text.  Since this
  3082.   % expands into a box, it must come within the paragraph, lest it
  3083.   % provide a place where TeX can split the footnote.
  3084.   \footstrut
  3085.   #1\strut}%
  3086. }%end \catcode `\@=11
  3087. % Set the baselineskip to #1, and the lineskip and strut size
  3088. % correspondingly.  There is no deep meaning behind these magic numbers
  3089. % used as factors; they just match (closely enough) what Knuth defined.
  3090. \def\lineskipfactor{.08333}
  3091. \def\strutheightpercent{.70833}
  3092. \def\strutdepthpercent {.29167}
  3093. \def\setleading#1{%
  3094.   \normalbaselineskip = #1\relax
  3095.   \normallineskip = \lineskipfactor\normalbaselineskip
  3096.   \normalbaselines
  3097.   \setbox\strutbox =\hbox{%
  3098.     \vrule width0pt height\strutheightpercent\baselineskip
  3099.                     depth \strutdepthpercent \baselineskip
  3100. % @| inserts a changebar to the left of the current line.  It should
  3101. % surround any changed text.  This approach does *not* work if the
  3102. % change spans more than two lines of output.  To handle that, we would
  3103. % have adopt a much more difficult approach (putting marks into the main
  3104. % vertical list for the beginning and end of each change).
  3105. \def\|{%
  3106.   % \vadjust can only be used in horizontal mode.
  3107.   \leavevmode
  3108.   % Append this vertical mode material after the current line in the output.
  3109.   \vadjust{%
  3110.     % We want to insert a rule with the height and depth of the current
  3111.     % leading; that is exactly what \strutbox is supposed to record.
  3112.     \vskip-\baselineskip
  3113.     %
  3114.     % \vadjust-items are inserted at the left edge of the type.  So
  3115.     % the \llap here moves out into the left-hand margin.
  3116.     \llap{%
  3117.       %
  3118.       % For a thicker or thinner bar, change the `1pt'.
  3119.       \vrule height\baselineskip width1pt
  3120.       %
  3121.       % This is the space between the bar and the text.
  3122.       \hskip 12pt
  3123.     }%
  3124. % For a final copy, take out the rectangles
  3125. % that mark overfull boxes (in case you have decided
  3126. % that the text looks ok even though it passes the margin).
  3127. \def\finalout{\overfullrule=0pt}
  3128. % End of control word definitions.
  3129. \message{and turning on texinfo input format.}
  3130. \def\openindices{%
  3131.    \newindex{cp}%
  3132.    \newcodeindex{fn}%
  3133.    \newcodeindex{vr}%
  3134.    \newcodeindex{tp}%
  3135.    \newcodeindex{ky}%
  3136.    \newcodeindex{pg}%
  3137. % Set some numeric style parameters, for 8.5 x 11 format.
  3138. %\hsize = 6.5in
  3139. \newdimen\defaultparindent \defaultparindent = 15pt
  3140. \parindent = \defaultparindent
  3141. \parskip 3pt plus2pt minus2pt
  3142. \setleading{13pt}
  3143. \advance\topskip by 1.2cm
  3144. % Prevent underfull vbox error messages.
  3145. \vbadness=10000
  3146. % Following George Bush, just get rid of widows and orphans.
  3147. \widowpenalty=10000
  3148. \clubpenalty=10000
  3149. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  3150. % using an old version of TeX, don't do anything.  We want the amount of
  3151. % stretch added to depend on the line length, hence the dependence on
  3152. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  3153. \ifx\emergencystretch\thisisundefined
  3154.   % Allow us to assign to \emergencystretch anyway.
  3155.   \def\emergencystretch{\dimen0}%
  3156. \else
  3157.   \emergencystretch = \hsize
  3158.   \divide\emergencystretch by 45
  3159. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  3160. \def\smallbook{
  3161. % These values for secheadingskip and subsecheadingskip are
  3162. % experiments.  RJC 7 Aug 1992
  3163. \global\secheadingskip = 17pt plus 6pt minus 3pt
  3164. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  3165. \global\lispnarrowing = 0.3in
  3166. \setleading{12pt}
  3167. \advance\topskip by -1cm
  3168. \global\parskip 3pt plus 1pt
  3169. \global\hsize = 5in
  3170. \global\vsize=7.5in
  3171. \global\tolerance=700
  3172. \global\hfuzz=1pt
  3173. \global\contentsrightmargin=0pt
  3174. \global\deftypemargin=0pt
  3175. \global\defbodyindent=.5cm
  3176. \global\pagewidth=\hsize
  3177. \global\pageheight=\vsize
  3178. \global\let\smalllisp=\smalllispx
  3179. \global\let\smallexample=\smalllispx
  3180. \global\def\Esmallexample{\Esmalllisp}
  3181. % Use @afourpaper to print on European A4 paper.
  3182. \def\afourpaper{
  3183. \global\tolerance=700
  3184. \global\hfuzz=1pt
  3185. \setleading{12pt}
  3186. \global\parskip 15pt plus 1pt
  3187. \global\vsize= 53\baselineskip
  3188. \advance\vsize by \topskip
  3189. %\global\hsize=   5.85in     % A4 wide 10pt
  3190. \global\hsize=  6.5in
  3191. \global\outerhsize=\hsize
  3192. \global\advance\outerhsize by 0.5in
  3193. \global\outervsize=\vsize
  3194. \global\advance\outervsize by 0.6in
  3195. \global\pagewidth=\hsize
  3196. \global\pageheight=\vsize
  3197. % Define macros to output various characters with catcode for normal text.
  3198. \catcode`\"=\other
  3199. \catcode`\~=\other
  3200. \catcode`\^=\other
  3201. \catcode`\_=\other
  3202. \catcode`\|=\other
  3203. \catcode`\<=\other
  3204. \catcode`\>=\other
  3205. \catcode`\+=\other
  3206. \def\normaldoublequote{"}
  3207. \def\normaltilde{~}
  3208. \def\normalcaret{^}
  3209. \def\normalunderscore{_}
  3210. \def\normalverticalbar{|}
  3211. \def\normalless{<}
  3212. \def\normalgreater{>}
  3213. \def\normalplus{+}
  3214. % This macro is used to make a character print one way in ttfont
  3215. % where it can probably just be output, and another way in other fonts,
  3216. % where something hairier probably needs to be done.
  3217. % #1 is what to print if we are indeed using \tt; #2 is what to print
  3218. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  3219. % interword stretch (and shrink), and it is reasonable to expect all
  3220. % typewriter fonts to have this, we can check that font parameter.
  3221. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  3222. % Turn off all special characters except @
  3223. % (and those which the user can use as if they were ordinary).
  3224. % Most of these we simply print from the \tt font, but for some, we can
  3225. % use math or other variants that look better in normal text.
  3226. \catcode`\"=\active
  3227. \def\activedoublequote{{\tt \char '042}}
  3228. \let"=\activedoublequote
  3229. \catcode`\~=\active
  3230. \def~{{\tt \char '176}}
  3231. \chardef\hat=`\^
  3232. \catcode`\^=\active
  3233. \def^{{\tt \hat}}
  3234. \catcode`\_=\active
  3235. \def_{\ifusingtt\normalunderscore\_}
  3236. % Subroutine for the previous macro.
  3237. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  3238. % \lvvmode is equivalent in function to \leavevmode.
  3239. % Using \leavevmode runs into trouble when written out to
  3240. % an index file due to the expansion of \leavevmode into ``\unhbox
  3241. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  3242. % magic tricks with @.
  3243. \def\lvvmode{\vbox to 0pt{}}
  3244. \catcode`\|=\active
  3245. \def|{{\tt \char '174}}
  3246. \chardef \less=`\<
  3247. \catcode`\<=\active
  3248. \def<{{\tt \less}}
  3249. \chardef \gtr=`\>
  3250. \catcode`\>=\active
  3251. \def>{{\tt \gtr}}
  3252. \catcode`\+=\active
  3253. \def+{{\tt \char 43}}
  3254. %\catcode 27=\active
  3255. %\def^^[{$\diamondsuit$}
  3256. % Set up an active definition for =, but don't enable it most of the time.
  3257. {\catcode`\==\active
  3258. \global\def={{\tt \char 61}}}
  3259. \catcode`\@=0
  3260. % \rawbackslashxx output one backslash character in current font
  3261. \global\chardef\rawbackslashxx=`\\
  3262. %{\catcode`\\=\other
  3263. %@gdef@rawbackslashxx{\}}
  3264. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  3265. {\catcode`\\=\active
  3266. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  3267. % \normalbackslash outputs one backslash in fixed width font.
  3268. \def\normalbackslash{{\tt\rawbackslashxx}}
  3269. % Say @foo, not \foo, in error messages.
  3270. \escapechar=`\@
  3271. % \catcode 17=0   % Define control-q
  3272. \catcode`\\=\active
  3273. % Used sometimes to turn off (effectively) the active characters
  3274. % even after parsing them.
  3275. @def@turnoffactive{@let"=@normaldoublequote
  3276. @let\=@realbackslash
  3277. @let~=@normaltilde
  3278. @let^=@normalcaret
  3279. @let_=@normalunderscore
  3280. @let|=@normalverticalbar
  3281. @let<=@normalless
  3282. @let>=@normalgreater
  3283. @let+=@normalplus}
  3284. @def@normalturnoffactive{@let"=@normaldoublequote
  3285. @let\=@normalbackslash
  3286. @let~=@normaltilde
  3287. @let^=@normalcaret
  3288. @let_=@normalunderscore
  3289. @let|=@normalverticalbar
  3290. @let<=@normalless
  3291. @let>=@normalgreater
  3292. @let+=@normalplus}
  3293. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  3294. % That is what \eatinput is for; after that, the `\' should revert to printing
  3295. % a backslash.
  3296. @gdef@eatinput input texinfo{@fixbackslash}
  3297. @global@let\ = @eatinput
  3298. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  3299. % the first `\{ in the file would cause an error. This macro tries to fix
  3300. % that, assuming it is called before the first `\' could plausibly occur.
  3301. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  3302. %% These look ok in all fonts, so just make them not special.  The @rm below
  3303. %% makes sure that the current font starts out as the newly loaded cmr10
  3304. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  3305. @textfonts
  3306. @c Local variables:
  3307. @c page-delimiter: "^\\\\message"
  3308. @c End:
  3309.